ajax - sometimes works - sometimes not working

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

ajax - sometimes works - sometimes not working

Post by ddragas »

Hi all

As this is my first contact with ajax I need some help.
There are 2 tables and 2 php scripts. User inserts into first table lets say 10 000 - 20 000 recordsets, and later second script handles those recordsets, and if handling was successful - it transfers to second table, and deletes from first table.

This is what I need to accomplish

Now I have implemented ajax using prototype bat there are some problems described below.

First script (executable) is working ok (inserting recordsets into first table), and after first script is done there is started second script - witch is not executed every time. I have noticed that when number of data posted from form to first script is big (10 000) - second script doesn't start, but if there is only submitted a few (<=20) then everything is working fine.

here is javascript code

Code: Select all

 
<script src="../prototype/prototype.js" type="text/javascript"></script>
<script type="text/javascript">
function init () {
    $('Submit').onclick = function () {
        sendData();
        sendData1();
     }
}
function sendData () {
    var url = 'firstScript.php';
    var pars = Form.serialize('myForm');
    var myAjax = new Ajax.Request( url, {method: 'post', parameters: pars, onLoading: showLoad, onComplete: showResponse} );
}
function sendData1 () {
    var url = 'secondScript.php';
    var pars = Form.serialize('myForm');
    var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars} );
}
function showLoad () {
    $('load').style.display = 'block';
}
function showResponse (originalRequest) {
    var newData = originalRequest.responseText;
    $('load').style.display = 'none';
    $('status').innerHTML = newData;
}
 
 
</script>
 
 
this is code that "glues" ajax with php scripts.

There is nothing wrong with php scripts (tested)

If somebody can help me I would appreciate it

Thank you

Kind regards
devendra-m
Forum Contributor
Posts: 111
Joined: Wed Sep 12, 2007 3:16 am

Re: ajax - sometimes works - sometimes not working

Post by devendra-m »

I have noticed that when number of data posted from form to first script is big (10 000) - second script doesn't start, but if there is only submitted a few (<=20) then everything is working fine.
you need some time delay between first ajax and second ajax otherwise second ajax will be left out
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

Re: ajax - sometimes works - sometimes not working

Post by ddragas »

Thank you for reply

works now
Post Reply