I'm trying to refresh some part of a page with an async call with JQuery. Part of the code you can see here.
success: function (data, status, xhr) {
var $result = $(data);.....etc
Now when I inspect 'data' and '$result' the HMTL-strings are not the same. For example:
Snippet from data:
<div class='divLoading'>
<img src='/Content/Icons/load.png' />
</div>
<div class='divGridContent'>
<div id="divGridMenu" class="divGridMenu">
<div id="divGridMenuContent" class="divGridMenuContent">
This is 'good' HTML, but when I inspect $result:
Snippet from $result:
<DIV class=divLoading><IMG src开发者_如何学运维="/Content/Icons/load.png"> </DIV>
<DIV class=divGridContent>
<DIV id=divGridMenu class=divGridMenu>
<DIV id=divGridMenuContent class=divGridMenuContent>
How can this be?
I think it's because of this statement:
var $result = $(data);
This will turn $result in a jquery object not an html string. This will probable return a normal html string:
var #result = $(data).html();
But in that case, you could also this:
var $result = data;
精彩评论