Sikret Miseon
Sikret Miseon

Reputation: 557

jquery inquiry regarding the post method

http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/

i am currently reading the tutorial and paused at the "Pass Parameters Through the GET Method" part.

$("#load_get").click(function(){  
    $("#result")  
        .html(ajax_load)  
        .load(loadUrl, "language=php&version=5");  
}); 

looking at the second parameter of the .load function, is it necessary to pass those values when load the php file? Could i leave it blank?

Upvotes: 2

Views: 103

Answers (2)

voigtan
voigtan

Reputation: 9031

Depends on what your PHP file needs to display its content, if you aren't using those Querystrings values then don't include those.

Upvotes: 0

James Allardice
James Allardice

Reputation: 165971

Yes, you could leave it blank. The only required argument is the first one (the URL). See the jQuery docs. Here's the relevant part. Arguments in square brackets are optional:

.load( url, [data], [complete(responseText, textStatus, XMLHttpRequest)] )

For example, the following will simply load whatever is at loadUrl into the element selected by #someElement:

$("#someElement").load(loadUrl);

Also note that despite how it may appear, the complete callback does not have to be the third argument. You can simply miss out the data argument if you don't need it:

$("#someElement").load(loadUrl, function() {
    //Done!
});

Upvotes: 2

Related Questions