0

In page I use jQuery .load() to apply database changes without reloading, have 2 steps:

  1. load change.php?id=1&change=delete
  2. reload list of items

Its simply illustration, I have more options (change rank, change text...), but all is implemented identically.

Problem: someone script doesn't show list, if I have in list.php console.log('text'), text shows in console, but list of items are not in div.

It happens more when I have 1+ requests per second.

It is possible to reach absolute reliability?

Thank you, Rob.

PS. I use simply onclick=func() in button and the

function func(){ 
$('#div1').load('change.php?id=1&change=delete'); 
$('#div2').load('list.php'); 
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
rob756
  • 1
  • 1
  • probably duplicate of [How to send Ajax request on every 1s using JQuery?](http://stackoverflow.com/questions/5310118/how-to-send-ajax-request-on-every-1s-using-jquery) & [send multi ajax requests every 1 second](http://stackoverflow.com/questions/9316690/send-multi-ajax-requests-every-1-second) – Farshad Aug 23 '14 at 19:46

2 Answers2

0

did you check the response you get from the server? If not try this snippet

$( "#success" ).load( "/not-here.php", function( response, status, xhr ) {
  if ( status == "error" ) {
    var msg = "Sorry but there was an error: ";
    $( "#error" ).html( msg + xhr.status + " " + xhr.statusText );
  }
});
King Loui
  • 190
  • 9
0

I have solution.

  • Problem: delay in db update
  • Solution:

    function func(){
    $('#div1').load('change.php?id=1&change=delete', function (){

    $('#div2').load('list.php');
    });

It is good solution?

rob756
  • 1
  • 1