Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript or php - what is most efficient for updating?

I have several update methods in a javascript file, used for updating my ajax application, like so:

function updateByPk(layer, pk) {
   url = "get_auction.php?cmd=GetAuctionData&pk="+pk+"&sid="+Math.random();
   update(layer, url);
}


function updateByQuery(layer, query) {
   url = "get_records.php?cmd=GetRecordSet&query="+query+"&sid="+Math.random();
   update(layer, url);
}

function updateByPage(layer, query, pg) {
   url = "get_records.php?cmd=GetRecordSet&query="+query+"&pg="+pg+"&sid="+Math.random();
   update(layer, url);
}

I am wondering if it would be more efficient to do things like pagination and such strictly through php, simply by reloading the page, rather than using an ajax method. I am not sure which method is more efficient, or if there are advantages and disadvantages to each.

like image 527
Joshxtothe4 Avatar asked Sep 01 '26 16:09

Joshxtothe4


1 Answers

Paging with AJAX advantages:

  • Potentially less transmitted data, which means faster page loads and less bandwidth usage.
  • Smoother user experience

Paging without AJAX advantages:

  • Back and Forward buttons will work in the browser
  • You can have the URL of a specific page (although you can do this with AJAX too with the page.php#pagenumber trick)
  • Perhaps a bit easier to write and maintain
like image 121
Tamas Czinege Avatar answered Sep 03 '26 08:09

Tamas Czinege



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!