How can I use jQuery "load" to perform a GET request with extra parameters? How can I use jQuery "load" to perform a GET request with extra parameters? jquery jquery

How can I use jQuery "load" to perform a GET request with extra parameters?


Use $.param(data):

$("#output").load(    "server_output.html?" + $.param({        year: 2009,        country: "Canada"}));


According to the documentation you linked:

A GET request will be performed by default - but if you pass in any extra parameters in the form of an Object/Map (key/value pairs) then a POST will occur. Extra parameters passed as a string will still use a GET request.

So the simple solution is to convert your object to a string before passing it to the function. Unfortunately, the documentation doesn't specify the format the string should be in, but I would guess it would be the same as if you were generating the GET request manually.

$("#output").load(    "/server_output.html?year=2009&country=Canada");


$("#output").load("server_output.html?year=2009&country=Canada");