• Register

ACTIVE Network API Forums

API Forum

RSS Feed

Search API with jQuery issue

    • James Steward
    • Topic created 12 years ago

    I'm having trouble getting the Search API to work with jQuery. I've used the jQuery AJAX methods for other API's and have not had this problem before. Here's the code I'm using (I'm posting this with the demo API Key because I don't want to post my key to the internet, but I've tried with my Search API key and that doesn't work either): <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"> <script> $(document).ready(function () { $.ajax({ // the URL for the request url: "http://api.amp.active.com/search", data: { l: "98103", v: "json", num: 5, api_key: "wuhmn9ye94xn3xnteudxsavw" }, type: "GET", dataType: "jsonp", success: function (json) { var result = json; alert('Success'); }, error: function (xhr, status) { var err = xhr; alert("Sorry, there was a problem!"); }, complete: function (xhr, status) { //alert("The request is complete!"); } }); }); </Script> Anyone have any ideas what is wrong with this? James

    Message edited by James Steward 12 years ago

    Tags

  1. jarredd12 years ago

    Hi James,

    Thanks for bringing this to my attention. I'll look into this and get back to you asap. Please allow a couple days to determine the issue.

    Best regards, Jarred

  2. jarredd12 years ago

    There were a few missing things: (1) Closing script tag for query (2) Specify the "jsonp" attribute so the code knows what callback to use (3) I lower-cased the last </Script> tag - not sure if that was causing any issues.

    <html> <body> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> <script> $(document).ready(function () { $.ajax({ // the URL for the request url: "http://api.amp.active.com/search", data: { l: "98103", v: "json", num: 5, api_key: "wuhmn9ye94xn3xnteudxsavw" }, type: "GET", jsonp: "cb", dataType: "jsonp", success: function (json) { var result = json; alert('Success'); }, error: function (xhr, status) { var err = xhr; alert("Sorry, there was a problem!"); }, complete: function (xhr, status) { // alert("The request is complete!"); } }); }); </script> </body>

  3. James Steward12 years ago

    Thanks Jarred, It looks like it was specifying the jsonp attribute with the callback that did the trick. Can't believe I missed that ;-) James

  4. jarredd12 years ago

    Glad we can help you out! Let me know if there are any other problems.

    Best, Jarred

[ Page 1 of 1 ]