$。员额没有发射 [英] $.post not firing
问题描述
我有一些脚本是这样的:
I have some script like this:
$("#button").click(function () {
alert("before");
$.post("doAction.aspx?id=hotel", {},
function (response) {
});
alert("after");
return false;
});
在 $。POST
不点火。我真的不知道是什么错误。我在其他地方使用相同的脚本,它工作得很好。请帮帮忙。
the $.post
is not firing. I really don't know what the error is. I used the same script elsewhere and it worked fine. pls help out.
推荐答案
如果警报(之前)被解雇,你不必在浏览器开发控制台中的任何错误,JS的话.post的$也射击。我希望你得到一个错误响应,因为你还没有提供处理程序($。员额不允许你这样做),那么它只会消耗和忽略。尝试更改为
if the alert("before") is firing and you don't have any JS errors in your development console in the browser then the $.post is also firing. I would expect that you get an error response and since you haven't provided a handler ($.post doesn't allow you to do that) then it will simply be consumed and disregarded. Try changing to
$.ajax({
type:'POST',
url:"doAction.aspx?id=hotel",
data:{},
success:function(data){...},
error:function (xhr, status, errorThrown) {
console.log(xhr); //could be alert if you don't use the dev tools
},
dataType:"json"
});
我会相信你进入了错误处理程序然后
I'd believe you get into the error handler then
这篇关于$。员额没有发射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!