遇到麻烦我认为是一个相对简单的jQuery插件...
该插件应该通过ajax从php脚本中获取数据,以便为a添加选项<select>.ajax请求非常通用:
$.ajax({
url: o.url,
type: 'post',
contentType: "application/x-www-form-urlencoded",
data: '{"method":"getStates", "program":"EXPLORE"}',
success: function (data, status) {
console.log("Success!!");
console.log(data);
console.log(status);
},
error: function (xhr, desc, err) {
console.log(xhr);
console.log("Desc: " + desc + "\nErr:" + err);
}
});
Run Code Online (Sandbox Code Playgroud)
这似乎在Safari中运行良好.在Firefox 3.5中,REQUEST_TYPE服务器上的"OPTIONS"始终为"OPTIONS",并且不会显示$ _POST数据.Apache将请求记录为"OPTIONS"类型:
::1 - - [08/Jul/2009:11:43:27 -0500] "OPTIONS sitecodes.php HTTP/1.1" 200 46
Run Code Online (Sandbox Code Playgroud)
为什么这个ajax调用在Safari中工作,而不是Firefox,以及如何为Firefox修复它?
Response Headers Date: Wed, 08 Jul 2009 21:22:17 GMT Server:Apache/2.0.59 (Unix) PHP/5.2.6 DAV/2 X-Powered-By: PHP/5.2.6 Content-Length 46 Keep-Alive timeout=15, max=100 Connection Keep-Alive Content-Type text/html …
在iOS 5的iOS 5 Safari中使用最新版本的jQuery 1.6,我注意到我所有的ajax调用都失败了.这些相同的ajax调用在我尝试的所有其他浏览器上按预期工作,我很确定他们也在使用iOS 4的Safari版本(尽管我可能错了).还有其他人经历过这种行为吗?如果是这样,是否有修复或解决方法?下面是一个简单的jQuery AJAX调用的简单示例,该调用在iOS 5的Safari中返回错误.提前感谢任何见解!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
</head>
<body>
<a id="my-link" href="javascript:;">Click Me!</a>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#my-link").bind("click", function() {
jQuery.get("test.php", function(data) {
alert(data);
});
});
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)