I need to make a widget where one can enter some text, and my server api.example.com can act on, and respond back. The thing is, I need to make multiple calls to my server, before the client gets the final "completed report". I currently have the following code.
$('#widget-form').submit(function() {
       var jqxhr = $.ajax({
            url: "/startanalyzerp?string=someexampletext",
            crossDomain: true,
            dataType: 'json'
        })
        .success(function(report) {
            alert("success"+report.id);
        })
        .error(function() {
            alert("error");
        })
        .complete(function() {
            alert("complete");
        });
What /startanalyzerp does is returns a unique id (integer), which I need to pass to subsequent urls. I have the value of this integer with report.id.
What I want to be able to do is call the other functions crossdomain.
/step2?id=report.id
/step3?id=report.id
/step4?id=report.id
I've been able to do it on the same domain using:
$.each(endpoint_array, function(index,value) {
    $.getJSON(value,function(report) {
}); 
Where endpoint_array is a simple array in order of what endpoint I want to be called.
I'd love any help on this, I'm sure it's something simple I'm missing.
 
     
     
    