0

I am trying to create a timer that ever x minutes it will call to a server, get a JSON file and do something with it. The merits of that system are not in question right now, the question involves getting the JSON file. Currently I am using kimonify from KimonoLabs to create a JSON file from some other site. They suggest I use

function kimonoCallback(data) {
    // do something with the data
    // please make sure the scope of this function is global
  }

  $.ajax({
    "url":"http://www.kimonolabs.com/api/9ey3ljcs?apikey=d753b0c5546495826e7aaa5422f59e30&callback=kimonoCallback",
    "crossDomain":true,
    "dataType":"jsonp"
});

At the same time I was pursuing other methods and was getting a parse error, and I found this solution. So far both used &callback=

what is so special about &callback= that makes it more preferable to something like .done() or success: I am guessing it has something to deal with Access-Control-Allow-Origin.

2

The server you are making the call to will call your function when it's done. That way you don't have to parse the immediate response (which may not contain the JSON).

Say the server takes 10 seconds to do a long operation. Instead of leaving your connection open for 10 seconds it will respond immediately that it got your request. It will then start the operation and let you know when it's done by calling your function.

It's part of Asynchronous Programming

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.