Page 1 of 1

ajax - sometimes works - sometimes not working

Posted: Tue Jan 15, 2008 12:42 pm
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

Re: ajax - sometimes works - sometimes not working

Posted: Wed Jan 16, 2008 4:41 am
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

Re: ajax - sometimes works - sometimes not working

Posted: Fri Jan 18, 2008 2:19 am
by ddragas
Thank you for reply

works now