Jquery Ajax Returns Undefined
$('.updateDescriptionProduct').click( function() { if ( updateProductDescription(productID, description) == 'true') { alert('success!'); } else { alert('did not update'
Solution 1:
the return
applies to the callback. Try setting a variable in the initial function and setting the value in the callback, then returning it?
functionupdateProductDescription(productID, description) {
var ret = false;
$.ajax({
url: '/index.php/updateProductDescription',
global: false,
type: 'POST',
data: ({productID: productID, description: description}),
dataType: 'html',
async:false,
success: function(msg){
ret = msg;
}
});
return ret;
}
I haven't ever done an async
call but it seems this should work. Let me know if it doesn't.
Post a Comment for "Jquery Ajax Returns Undefined"