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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.