Javascript 如何检查ajax请求是否由特定url处理
我尝试使用ajax请求保存一个类别选项,并想知道如何检测ajax_attributes.phtml是否成功地处理了我的ajax请求。我的问题是,无论我指定什么url,它总是提醒它工作,即使我将url更改为像yadayada.phtml这样根本不存在的Javascript 如何检查ajax请求是否由特定url处理,javascript,php,ajax,magento,prototype,Javascript,Php,Ajax,Magento,Prototype,我尝试使用ajax请求保存一个类别选项,并想知道如何检测ajax_attributes.phtml是否成功地处理了我的ajax请求。我的问题是,无论我指定什么url,它总是提醒它工作,即使我将url更改为像yadayada.phtml这样根本不存在的 new Ajax.Request('ajax_attributes.phtml', { parameters: {categoryId: categoryId},
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...');
}
});
您可以尝试使用以下代码:
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...');
});
是jquery吗?我需要原型机而不是原型机是的,对不起,这是jQuery,我总是用它,我发现它更好。