我有这个功能
$.ajax({
url: aurl,
method: 'GET',
beforeSend: function (req) { req.setRequestHeader('Authorization', auth); },
cache: false,
dataType: "json",
error: function () {
//error code
},
success: function (t) {
//success code
}
});
但是,参数:
- 方法
- 发送前
- 缓存
被我的浏览器 FF3、IE8 和 Chrome 忽略。因此,无论放置在那里,都不会更改浏览器发送到给定 url 的请求,例如:无法将方法设置为“POST”,或者更重要的是,不能将任何授权参数作为请求的一部分放置,以便 HTTP 授权表单已处理。
另一个奇怪的行为是除非 数据类型:“json” 将不会发送或接收任何请求或响应,如使用 FF3 中的 LiveHTTPHeaders 所示。例如,如果数据类型:“xml”。
浏览器似乎正确处理了 URL。
遇到这些问题的人如何确保发送这些额外参数?
最佳答案
URL 是远程的还是本地的?
Note: All remote (not on the same domain) requests should be specified as
GET
when'script'
or'jsonp'
is thedataType
(because it loads script using a DOM script tag). Ajax options that require anXMLHttpRequest
object are not available for these requests. The complete and success functions are called on completion, but do not receive anXHR
object; thebeforeSend
anddataFilter
functions are not called.
以及cache
选项,默认值为:“dataType
' script
' 和 ' jsonp
' 为 false”
关于jquery - $.ajax 中的某些参数未传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/724920/