Jump to content

ajax call issue....


ajlisowski

Recommended Posts

So, I am making a jquery ajax call to a restful application. The call generates a url of:

 

http://geoapi.fwix.com/places.json?api_key=25645fa7e150&lat=39.8062&lng=-86.1407&range=2

 

Which if you go to that url you will see it properly generates JSON. However, looking at firebug, the call fails to get a response from the server.

 

my jquery code is as follows:

 

var latitude=$('#location_lat').val();
        var longitude=$('#location_long').val();

        var range=obj.range;
        var data='api_key='+obj.fwixAPI;
        data=data+'&lat='+latitude;
        data=data+'&lng='+longitude;
        data=data+'&range='+range;
        data=data+'&page_size='+10;
        $.ajax({
            type: "GET",
            url: 'http://geoapi.fwix.com/places.json',
            data: data,
            dataType: 'json',
            success: function(msg){
               system_obj.debug(msg);
            }
        });

 

Since the URL generated by the request is properly outputting JSON, I can not figure out why it is failing, any ideas?

Link to comment
https://forums.phpfreaks.com/topic/245986-ajax-call-issue/
Share on other sites

Yeah, Im assuming if it did, places.jsonp would be the correct format. That explains why when I tried changing my request type to jsonp, I did get a response, but it couldnt parse it.

 

Right now my solution is to make a proxy php page which simply routes the request and displays the result. This is working fine, but it brings up a concern.

 

Some APIs have a usage limitation based on IP. If I could send it directly via javascript, the IP would be that of the client. If i use the re-route through my php server, the IP will be that of the server and reach its limit much, much quicker. With the particular service I am using, it DOES have a 5000 query limit per user. But I believe that amount is reached via a unique user id passed with the request and not via IP. So I should be fine there, because I can just send the user ID or generate a random one for a guest and send that.

Link to comment
https://forums.phpfreaks.com/topic/245986-ajax-call-issue/#findComment-1263513
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.