jquery - Why so much problem with IE and Ajax? -


$.ajax({   type: 'post',   url: url +'/foo/',   data: {'pass': pass},   datatype: "json",   jsonp:'jsonp_callback',   success: function(data) {     if (data["success"] === "false") {       $("#password").val("");       $('.error-message').removeclass('hide')       $('.error-message').addclass('show')     }     else {       var tempurl="http://10.0.1.101:9000/bar/"       location.href=tempurl;     }   }, }); return false 

this working fine in mozilla, chrome, safari. not in ie. reason. returning suucess value server. if success true redirect tempurl. nothing happing here in ie. seems ajax not @ working in ie.

you're running "dangling comma" problem (the comma after closing } of success parameter). ie doesn't dangling commas in object literals, treats them syntax errors , script dies. (this isn't ie bug, it's reasonable interpretation of earlier spec; newest spec allows comma, though, , fixed in ie8.) off-topic: ie has similar, different, issue dangling commas in array literals (which still in ie8).

more on both isuses this article, basically:

$.ajax({   type: 'post',   url: url +'/foo/',   data: {'pass': pass},   datatype: "json",   jsonp:'jsonp_callback',   success: function(data) {     if (data["success"] === "false") {       $("#password").val("");       $('.error-message').removeclass('hide')   // <== recommend ; here       $('.error-message').addclass('show')      // <== ; here     }     else {       var tempurl="http://10.0.1.101:9000/bar/" // <== ; here       location.href=tempurl;     }   }, // <== comma problem }); return false                                    // <== ; here 

see note near bottom. remove comma , you're fine. things improving (as outlined in linked article above), maximum compatibility in wild, need watch while longer.

(the other notes off-topic, again, recommend fixing well, never rely on semicolon insertion.)


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -