Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net mvc and jquery
    primarykey
    data
    text
    <p>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 <strong>jQuery $.ajax() function.</strong> Problem is that ajax is NOT returning an XML Doc from my controller; it returns some formatted Html.</p> <p><em><strong>Example:</em></strong> I <strong>can</strong> 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 <strong>@Model object:</strong></p> <pre><code>@model RazorMvc.Models.PortfolioResponse @{ ViewBag.Title = "PortfolioList"; } ... &lt;div class="XmlResp"&gt; &lt;@Html.Raw(@Model.XmlPortfolioResponse.OuterXml.ToString())&gt; &lt;/div&gt; </code></pre> <p>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:</p> This is a test div !!! <p>What's getting displayed is some formatted HTML as follows:</p> <p>Wow are we getting somewhere ?!!! My company SolutionsRegisterLog inHomeAboutContactPortfoliosPortfolioListPortfolio ListingThis is a test div !!!© 2012 - My ASP.NET MVC ApplicationFacebookTwitter</p> <p>Here is the jQuery code. I would hope to get an XML doc in the DATA object:</p> <pre><code>&lt;script type="text/javascript"&gt; $.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"); } }); </code></pre> <p>Some guidance and advice would be greatly appreciated. Thanks, Bob</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload