开发者

Jquery form plugin is ignoring ajaxSetup settings

开发者 https://www.devze.com 2023-03-20 05:29 出处:网络
I am trying to use $.ajaxSetup() to set global data to be sent in every ajax request. According to here, 开发者_StackOverflow中文版what I am trying should works fine.

I am trying to use $.ajaxSetup() to set global data to be sent in every ajax request.

According to here, 开发者_StackOverflow中文版what I am trying should works fine.

However, some of the ajax calls in my app are forms using the form plugin. Those calls doesnt seems to include the data I set in $.ajaxSetup(). I believe it's also using jquery $.ajax() , but it just simply doesnt work. So I am write to ask if there's some way to achieve it.

Here's a demo page to show what I am trying to do. http://jsfiddle.net/FSLyA/9/


Your jsfiddle example is not the same thing as the blog post.

You are just using the vanilla URL of google, yahoo etc... - what do you expect to happen? An ajax call will not just send back that page no matter if you use a form or anything else to send data to it. The purpose of an ajax call is to get the other part (the server side script) to process your data and send some data back.

I assume your example was not the real code you are using. Perhaps you could post that?

Also it might be that the same domain policy is coming into play, or that actually your whole understanding of Ajax is limited at the moment. I'm not sure which it is.


By reviewing the code of the form plugin, I have found that the plugin looks up all form elements and create a query string with those data, which overwrites the data object set in $.ajaxSetup(). And so the trick doesn't work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号