I'm currently facing problem intercepting AJAX Calls. I know how I can somehow intercept AJAX Calls at some level by ajaxSetup(). But I have one question: ajaxSetup() intercepts all calls within the document. I DON'T WANT TO DO THAT. What I'm really trying to do is changing the default type 'GET' to 'POST' of some calls. And for that I need to use ajaxSetup(). Is there any way how can I 'setup' only selected or 'ajax calls which follow a certain URL pattern'? Thank you.
1条回答 默认 最新
- larry*wei 2016-01-16 10:17关注
Use
beforeSend
in$.ajaxSetup()
$.ajaxSetup({ beforeSend: function (jqXhr, settings) { settings.type = settings.url.indexOf("foo") > -1 ? "POST" : "GET" } });
GET request changed to POST -> fiddle
(check the network panel for the changed submission method)解决 无用评论 打赏 举报