jquery ajax error 404,jQuery Ajax 404 Handling

博客作者遇到一个在使用AJAX发送数据时遇到的问题,由于PHP生成的URL与AJAX请求的数据部分包含了相同的参数名`action`,导致请求中的`action`值被覆盖。这个问题在Firebug中并不明显,因为显示的URL并未反映出实际发送的带有`getpoints`的请求。解决方法是确保URL和AJAX数据中的参数名不重复。这个经验分享可能对遇到类似问题的开发者有所帮助。
摘要由CSDN通过智能技术生成

I had a very similar result/problem. The bottom line is that I failed to make sure that my URL did not contain any of the same param names in the data section of the ajax function.

The reason for me, was that I generated the URL with php code to get a url

pines_url('com_referral', 'sendhttprequest')

which outputs to a url with a parameter

option=com_referral

and a parameter

action=sendhttprequest

My BIG problem was that I was also trying to send a param "action" in the data section of an AJAX function.

data: {"action": "getpoints"}

So the second action was overriding it "getpoints" does not exist, but the tricky part is that firebug would obviously not tell me the url with getpoints, it would tell me the url as sendhttprequest.

Hope that wasn't confusing, but I also hope this helps someone else with a similar problem!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值