问题描述:

I have written this ajaxform function with a success function which is being called on sumiting the form. The ajaxform works AWESOMELY in any browser other than IE. I can´t understand why IE is not passing the function.

AjaxForm:

function setupAjaxForm(form_class, updateStatus){

var form = '.'+form_class;

var form_action = $(form).attr('action');

var form_url = form_action+"ajax/";

var submitOptions = {

url : form_url,

type : 'POST',

dataType : 'json',

success : function(json) {

var results = json.results;

alert(results);

if(results == "success"){

updateStatus(json);

}else{

alert(" FAIL ");

}

}

};

$(form).ajaxForm(submitOptions);

}

Success function:

function addProductCartStatus(json){

alert(" Entered for jquery ");

}

Calling function

$(document).ready(function(){

$('.addto_cart').click(function(){new setupAjaxForm('add_cartForm',addProductCartStatus);});

});

网友答案:

this answer goes mainly to your latest comment

internet explorer is more stiff in some cases. this line result = "success" as mentioned is wrong and converts result into a string with the word success in it and is always true so it always updates

also its recommended to add a error:function(){} on your ajax call

网友答案:
if(result = "success")

Should be

if(result == "success")

And you should use "{" for your if

if(result == "success") {
   updateStatus(json);
} else {
相关阅读:
Top