Javascript or php - what is the most efficient for updating?

I have several update methods in a javascript file that is used to update my ajax application, for example:

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 so strictly through php, just reloading the page and not using the ajax method. I am not sure which method is more efficient, or if there are advantages and disadvantages for everyone.

+3
source share
4 answers

If I have a question, then you ask whether to do pagination and the like through Javascript + AJAX or do it through a call to the server?

, . AJAX , "bling" (, : P)

, " " ( - Javascript " ".

Javascript , 1) . 2) "". AJAX, . ( ), .

AJAX , , - , , , . .. ..

+1

AJAX:

  • , .

AJAX:

  • "" "" .
  • URL- ( AJAX page.php # pagenumber)
  • ,
+2

Ajax . reset, , , . ; , .

, ( doodads). javascript, . , , , ajax. degredation Ajax, .

<a href="/search?term=foo&amp;page2" onclick="loadPageViaAjax(2); return false">
  Next
</a>

, javascript. javascript , onclick, ajax return false. javascript , onclick , .

+1

. AJAX , , , ( , ). AJAX , , javascript ( ) . , javascript AJAX.

0

Source: https://habr.com/ru/post/1702944/


All Articles