I try to use an ajax request to save a category option and wonder how could I detect whether my ajax request has been successfully handled by ajax_attributes.phtml. My issue is no matter what url I specify, it always alerts it works, even I change the url into something like yadayada.phtml
,which is not existed at all.
new Ajax.Request('ajax_attributes.phtml',
{
parameters: {categoryId: categoryId},
onSuccess: function(response) {
// Handle the response content...
alert('it works');
},
onFailure: function(){
alert('Something went wrong...');
}
});
You can try with this code :
var request = $.ajax({
url: "script.php",
type: "POST",
data: { categoryId: categoryId},
dataType: "html"
});
request.done(function( msg ) {
alert('it work');
});
request.fail(function( jqXHR, textStatus ) {
alert('Something went wrong...');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.