Internet explorer Jquery post不在IE 8或更早版本中工作
所以这个功能可以在除IE之外的所有浏览器中使用。我只能访问IE 8,所以不能说新版本是否有效。我无法访问PHP或它如何调用SQL DB,因此我不能确定它是javascript。IE中从未触发此警报Internet explorer Jquery post不在IE 8或更早版本中工作,internet-explorer,jquery,post,internet-explorer-8,Internet Explorer,Jquery,Post,Internet Explorer 8,所以这个功能可以在除IE之外的所有浏览器中使用。我只能访问IE 8,所以不能说新版本是否有效。我无法访问PHP或它如何调用SQL DB,因此我不能确定它是javascript。IE中从未触发此警报 $.post( 'http://foo/geo/getGeoResultsByGeoId.php', {geoId: 1}, function(data){ alert('inside'); var DBinfo = $.parseJSON(data); if(DBin
$.post( 'http://foo/geo/getGeoResultsByGeoId.php', {geoId: 1}, function(data){
alert('inside');
var DBinfo = $.parseJSON(data);
if(DBinfo.data.length == sites.length) {
for (var i=0; i<sites.length; i++) {
sites[i].votesUp = Number(DBinfo.data[i].votesUp);
sites[i].votesDown = Number(DBinfo.data[i].votesDown);
sites[i].mag = getMagnitude(Number(DBinfo.data[i].votesUp), Number(DBinfo.data[i].votesDown));
createGraph(sites[i]);
}
setMarkers(map, sites);
}
});
$.post('http://foo/geo/getGeoResultsByGeoId.php“,{geoId:1},函数(数据){
警惕(“内部”);
var DBinfo=$.parseJSON(数据);
if(DBinfo.data.length==sites.length){
对于(var i=0;i我认为问题在于两个不同的成功回调的时间。这应该有效:
$.post( 'http://fooURL/getGeoResultsByGeoId.php', {geoId: 1}, function(data){
alert('inside');
var DBinfo = $.parseJSON(data);
if(DBinfo.data.length == sites.length) {
for (var i=0; i<sites.length; i++) {
sites[i].votesUp = Number(DBinfo.data[i].votesUp);
sites[i].votesDown = Number(DBinfo.data[i].votesDown);
sites[i].mag = getMagnitude(Number(DBinfo.data[i].votesUp), Number(DBinfo.data[i].votesDown));
createGraph(sites[i]);
}
setMarkers(map, sites);
}
});
$.post('http://fooURL/getGeoResultsByGeoId.php“,{geoId:1},函数(数据){
警惕(“内部”);
var DBinfo=$.parseJSON(数据);
if(DBinfo.data.length==sites.length){
对于(var i=0;i如果您的返回数据是JSON,并且您正在进行跨域请求,那么类似的内容如何:
$.ajax({
url: 'http://fooURL/getGeoResultsByGeoId.php?callback=?',
data : {geoId: 1},
dataType : 'JSONP',
success: function(data) {
DBinfo = data;
alert('inside');
if(DBinfo.data.length == sites.length) {
for (var i=0; i<sites.length; i++) {
sites[i].votesUp = Number(DBinfo.data[i].votesUp);
sites[i].votesDown = Number(DBinfo.data[i].votesDown);
sites[i].mag = getMagnitude(Number(DBinfo.data[i].votesUp), Number(DBinfo.data[i].votesDown));
createGraph(sites[i]);
}
setMarkers(map, sites);
}
},
type : 'POST'
});
$.ajax({
网址:'http://fooURL/getGeoResultsByGeoId.php?callback=?',
数据:{大地水准面:1},
数据类型:“JSONP”,
成功:功能(数据){
DBinfo=数据;
警惕(“内部”);
if(DBinfo.data.length==sites.length){
对于(var i=0;i在标记开始后将这一行放在HTML中
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
数据类型可以是xml
、json
、text
、或jsonp
或数据类型的组合。因此,根据您的数据类型选择,它会很好地工作。它至少对我有效,不知道我是否错了?为什么您有两个成功函数?正如@wirey所述,您不需要。success()如果您正在使用回调,因为回调本质上是一个.success()。请选择一个或另一个。@kennypu:听起来像是我的答案。@user1310774这是一个跨域请求吗?IE不支持CORS,就像现代浏览器一样。(它需要使用不同的对象来发送请求,这是jQuery不支持的。)是的,这是一个跨域请求。没有jQuery的解决方案是什么?很抱歉,这两次成功只是我为了让它工作而尝试了基本上所有的事情。一次成功中的所有事情都有同样的问题。很抱歉,这两次成功是我为了让它工作而尝试了基本上所有的事情。同样的问题一切顺利。@user1310774您还可以提供一个解析的JSON的示例吗?您在数据类型之后缺少了一个“,”,但是的,$.ajax也不起作用。JSON看起来像这样{“数据”:[{“名称”:“Brian Kelly”,“votesUp”:“3”,“votesDown”:“2”},{“名称”:“Rich Ellerson”,“votesUp”:“0”,“votesDown”:“0”}如果您将警报(“内部”)更改为警报(数据),您会得到什么;
$.post(url,
function(){
//your content here
},'dataType')
.fail(function(jqXHR,status)
{
});