Welcome Guest, Not a member yet? Register   Sign In
two ajax calls are slow!
#1

[eluser]keepyourweb[/eluser]
In my app I have two ASYNC ajax calls (jQuery) that I control with Deferred method ( $.when(...).then(...) ); They call a function on my controller that prints a small json, but they are slow; If I remove one of these is fast, why?
The problem is only with CodeIgniter, if the ajax calls referencing a external php file (no controller function) is fast.

PS: The fault is not the controller's functions , because do an echo of a handwritten json.
PPS: The ajax calls are on an external java file.

Thank.
#2

[eluser]n0xie[/eluser]
What does firebug tell you?
#3

[eluser]keepyourweb[/eluser]
nothing, what should he tell?
#4

[eluser]n0xie[/eluser]
Well it should give a considerable slow response in your NET tab. You might want to investigate what exactly gets sent and what the response is. It might give you a clue what is slowing down your request.
#5

[eluser]keepyourweb[/eluser]
He does not tell me anything special. But there is a large time differences, the first call 280ms and the second 1.26s! Even if I reverse.
#6

[eluser]n0xie[/eluser]
That is weird. I'm pretty much clueless to where this behaviour comes from Smile
#7

[eluser]keepyourweb[/eluser]
Maybe there are sessions that are blocking the calls, I do not know.
#8

[eluser]John Murowaniecki[/eluser]
I work a lot with ajax and CI, eventually I get some slow behavior but normally all request/posts are fast (very fast).. But I´ve decided to test, so there´s my controller:
Code:
class ajax extends Controller
{
    function async($arg = NULL)
    {
        die(date('Y-m-d H:m:i s')." $arg");
    }
    #
}
And those are my js/jquery functions:
Code:
var extc = 0;
//

function func_one()
{
    ini = ( date.getMinutes() * 60 ) + date.getSeconds() + date.getMilliseconds();
    $.ajax({
        url: 'http://yourdomain/yourapplicationfolder/ajax/async/one/'+ini,
        success: function(data) {
            console.log(data);
            if( ++extc < 100 ) func_two();
        }
    });
    end = ( date.getMinutes() * 60 ) + date.getSeconds() + date.getMilliseconds();
    console.log((end - ini)+' miliseconds to load data from func_one');
}
//

function func_two()
{
    ini = ( date.getMinutes() * 60 ) + date.getSeconds() + date.getMilliseconds();
    $.ajax({
        url: 'http://yourdomain/yourapplicationfolder/ajax/async/two/'+ini,
        success: function(data) {
            console.log(data);
            if( ++extc < 100 )func_one();
        }
    });
    end = ( date.getMinutes() * 60 ) + date.getSeconds() + date.getMilliseconds();
    console.log((end - ini)+' miliseconds to load data from func_two');
}
//

function func_run()
{
    extc = 0;
    func_one();
}
//

So when I execute the func_run() on the firebug I get a nice result despite I´ve sending almost nothing (and receiving almost nothing). I'm treating this as the "end" of the request the termination of the function (and not the actual return ajax).

Did you check your error log?
#9

[eluser]keepyourweb[/eluser]
Thank you for your interest!

I don't know why, but now is fast, normal! Tomorrow I try again, it is very strange.
#10

[eluser]nikes[/eluser]
Don't understand.




Theme © iAndrew 2016 - Forum software by © MyBB