Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to pass parameters to jQuery's .load()

Tags:

jquery

ajax

People also ask

What is the 3 parameters of load () method?

This callback function has three different parameters: parameter 1: It contains the result of the content if the method call succeeds. parameter 2: It contains the status of the call function. parameter 3: It contains the XMLHttpRequest object.

How do you load a method?

jQuery load() Method The load() method loads data from a server and puts the returned data into the selected element. Syntax: $(selector). load(URL,data,callback);


In the first case, the data are passed to the script via GET, in the second via POST.

http://docs.jquery.com/Ajax/load#urldatacallback

I don't think there are limits to the data size, but the completition of the remote call will of course take longer with great amount of data.


As Davide Gualano has been told. This one

$("#myDiv").load("myScript.php?var=x&var2=y&var3=z")

use GET method for sending the request, and this one

$("#myDiv").load("myScript.php", {var:x, var2:y, var3:z})

use POST method for sending the request. But any limitation that is applied to each method (post/get) is applied to the alternative usages that has been mentioned in the question.

For example: url length limits the amount of sending data in GET method.