Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anders Aleborg 35 posts 67 karma points
    Aug 16, 2012 @ 21:32
    Anders Aleborg
    0

    /Base and async

    Hi,

     

    I have run in to a weird problem, this just just might be an jquery issue but I put it here any way:

    If I send 10 requests to a rest function at the same time from jquery, and I know that each response will take about 5 seconds to retrieve from the api then I should get a response from all requests almost at the same time, right? But it isn't the case, it takes 50 seconds.

    Response 1 after 5 seconds
    Response 2 after 10 seconds etc...

    Code:

       for( i=0;i<10;i++){
    sTest("Anders "+i);
    }
    function sTest(myname){
    $.ajax({
    type: "GET",
    async: true,
    contentType: "application/json; charset=utf-8",
    cache: false,
    dataType: "json",
    url: '/base/myApi/SyncTest/' + myname + '.aspx',
    success: function (response) {
    $('#htmltest').append(response.Description+'<br />');
    },
    error: function (response2) {
    }
    });
    }
           [RestExtensionMethod()]
    public static string SyncTest(string myName)
    {
    Thread.Sleep(5000);
    return JsonConvert.SerializeObject(new ReturnResult() { Code = "100", Description = "Hello "+myName+"!" });
    }

    Any ideas? How can I get an asynchronus response?

  • Anders Aleborg 35 posts 67 karma points
    Aug 16, 2012 @ 21:42
    Anders Aleborg
    0

    Is /Base limiting to 1 simultanous request per session?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies