Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8140675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:14:31+00:00 2026-06-06T12:14:31+00:00

In my MVC view (using VS 2012 RC), I’m attempting to use jQuery to

  • 0

In my MVC view (using VS 2012 RC), I’m attempting to use jQuery to parse XML data returned from my Controller. However, my focus is to make use of the jQuery $.ajax() function.
Problem is that ajax is NOT returning an XML Doc from my controller; it returns some formatted Html.

Example:
I can indeed return it directly to my view inside a , but I don’t want that entire XML doc displayed that way. For example, get XML from the @Model object:

@model RazorMvc.Models.PortfolioResponse
@{
    ViewBag.Title = "PortfolioList";
}              
 ...
<div class="XmlResp">
        <@Html.Raw(@Model.XmlPortfolioResponse.OuterXml.ToString())>
</div> 

HOWEVER, I would much prefer to use $.ajax() to retrieve my XML Doc. The only problem is that the return value from my Controller code is NOT the XML; it’s returning some formatted HTML text:

This is a test div !!!

What’s getting displayed is some formatted HTML as follows:

Wow are we getting somewhere ?!!! My company SolutionsRegisterLog inHomeAboutContactPortfoliosPortfolioListPortfolio ListingThis is a test div !!!© 2012 – My ASP.NET MVC ApplicationFacebookTwitter

Here is the jQuery code. I would hope to get an XML doc in the DATA object:

<script type="text/javascript">
    $.ajax({
        url: "/Portfolios/PortfolioList",
        type: "POST", 
        async: true,
        success: function(data){
            if (!data)
                alert("No xml data returned.");
            else{
                var $xml = $(data);
                var $title = $xml.find("portfolioSummary").text();

                $('.xmlTest').text("Wow are we getting somewhere ?!!!");
                $('.xmlTest').append($xml.text());
                alert("success!");                
            }
        },
        error: function (error) {
            alert("failed");
        }

    });

Some guidance and advice would be greatly appreciated.
Thanks,
Bob

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:14:32+00:00Added an answer on June 6, 2026 at 12:14 pm

    You don’t need a view. You could return the XML directly from your controller action:

    [HttpPost]
    public ActionResult PortfolioList()
    {
        string xml = ...
        return Content(xml, "text/xml");
    }
    

    Now, since you have set the proper content type response header, jQuery will know how to parse it and in your success callback you will be able to directly work with this XML stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Client Id for Property (ASP.Net MVC) In my View I'm using jquery
I want to load another controller's view using MVC. I do it using something
I'm using some javascript/jquery in an asp.net mvc view and I'm appending some html
Traditionally, I have built MVC applications using view models with Data Annotations attributes, and
I am using MVC-View Model, EF Model first I am having problems with two
I am using ASP.NET MVC 2, and am using a view-model per view approach.
I'm using the spark view engine with my asp.net mvc application. In my aspx
I'm using ASP.NET MVC 3 and the helper @Html.Raw in my view. I'm passing
Using ASP MVC and Entity Framework. In the view, you have a page declaration
I'm using ASP.NET MVC 2 and here's the issue. My View Model looks something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.