Javascript 无法使用webservice显示记录
此代码工作正常,但不显示记录。在警报中,如果我从文件中获取记录,其工作正常Javascript 无法使用webservice显示记录,javascript,ajax,jquery,jquery-mobile,Javascript,Ajax,Jquery,Jquery Mobile,此代码工作正常,但不显示记录。在警报中,如果我从文件中获取记录,其工作正常 $j().ready(function(){ var result =$j.ajax({ type: "GET", url: "webService address", dataType :'json', contentType:'appli
$j().ready(function(){
var result =$j.ajax({
type: "GET",
url: "webService address",
dataType :'json',
contentType:'application/json; charset =utf-8',
success:function(data)
{
$j.each(data, function(index,element){
alert("Successful here: "+element);
});
}
});
alert("result"+result);
});
欢迎来到异步的奇妙世界 首先,jQueryGet不返回需要回调处理的数据(与您的帖子中的一样) 这可能无法正常工作,因为jQuery ajax是异步的,当GET仍在读取数据且尚未准备就绪时,可能会弹出警报 检查Jquery ajax: javascript并没有等待AJAX完成,而是继续前进。这就是它被称为异步的原因。如果需要同步调用,请使用
async:false
var result = null;
$j(document).ready(function(){
$j.ajax({
type: "GET",
url: "webService address",
dataType :'json',
contentType:'application/json; charset =utf-8',
success:function(data)
{
result = data;
$j.each(data, function(index,element){
alert("Successful here: "+element);
});
}
});
alert("result"+result);
});
$.ajax({
type: "GET",
url: "webService address",
dataType :'json',
contentType:'application/json; charset =utf-8'
}).done(function(data) {
console.log(data);
});