use*_*789 5 ajax jquery jquery-load
我想知道API结果如何在响应到来时加载.
我认为使用数据库中的ajax我们可以得到.但这里来自API(实时结果)SOAP API.
有什么建议?
编辑
我目前的ajax功能是
$.ajax({
type: "get",
url: "<?=base_url()?>search/showresults",
cache: false,
data:datastring,
beforeSend:function(){
$('#resultloader').show();
},
success: function(response){
$('#resultloader').hide(500);
$('#showflightresults').html(response);
},
error: function(){
//alert('Error while Sending request..');
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢
尝试将 dataType 设置为xml并将 processData 设置为false并检查。
$.ajax({
type: "get",
url: "<?=base_url()?>search/showresults",
cache: false,
data:datastring,
processData: false,
dataType:"xml",
beforeSend:function(){
$('#resultloader').show();
},
success: function(response){
$('#resultloader').hide(500);
$('#showflightresults').html(response);
},
error: function(){
//alert('Error while Sending request..');
}
});
Run Code Online (Sandbox Code Playgroud)
编辑:-
您需要遍历 php 数组。
var arrayFromPHP = <?php echo json_encode($arrayPHP) ?>;
$.each(arrayFromPHP, function (i, elem) {
// do your stuff
});
Run Code Online (Sandbox Code Playgroud)