Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load API results through ajax

I'm wondering that how API results can load as response comes.

similar functionality

I think using ajax from database we can get. But here from API(live results) SOAP API.

any suggestions?

EDIT

My current ajax function is

$.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..');
    }
});

Thank you

like image 586
user123456789 Avatar asked Mar 13 '14 10:03

user123456789


1 Answers

Try setting dataType as xml and processData as false and check.

$.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..');
    }
});

EDIT:-

You need to iterate through php array.

var arrayFromPHP = <?php echo json_encode($arrayPHP) ?>;

$.each(arrayFromPHP, function (i, elem) {
    // do your stuff
});
like image 142
Aditya Singh Avatar answered Oct 18 '22 11:10

Aditya Singh