I am using jQuery 1.4.3 to make an ajax call to an ASP.NET MVC 2 rest service. Since this rest service is on a different domain, I have to use jsonp. The issue I am running into is after upgrading from jQuery 1.4.2 to 1.4.3, I now get javascript errors when jQuery tries to remove the tag that was injected for the jsonp callback. The data from the rest service comes back fine.
After looking at the jQuery 1.4.3 file, i see that the error is occuring at this line:
if ( head ) {
head.removeChild( script );
}
After debugging that section in firebug, this is what happening. After the first ajax jsonp call to method getDetail(), the "script" variable has the following value which is in the "head" variable, so the call "head.removeChild(script);" suceeds and the script tag is removed.
<script src="http://localhost:63505/Locations/Detail/445?callback=fetchLocationInfoWindowCallback"></script>
On a Subsequent call to the same method getDetail() using ajax jsonp again, looking in the debugger, the "script" variable still has the following value, however the "head" variable no longer contains this script tag.
<script src="http://localhost:63505/Locations/Detail/445?callback=fetchLocationInfoWindowCallback"></script>
Instead this "script" variable should have the following value开发者_JS百科 which is contained within the "head" variable.
<script src="http://localhost:63505/Locations/Detail/335?callback=fetchLocationInfoWindowCallback"></script>
The jQuery 1.4.4 RC has a fix for this problem.
精彩评论