The load function can be simply HTML elements of a file in the current insert. This function is primarily for the "import" of HTML code in thought and therefore does not correspond to the typical Ajax request in the example a PHP script is accessed, the data from the database reads and / or knock against other server processes.
So much for the first theory, the function call is as follows:
1
| ) . load ( '/someFile #mydiv' ) ; $ ('# SomeElement'). Load ('/ somefile # myDiv'); |
So short that simple. In the element with id "someElement" divs, the entire contents of the "myDiv" loaded id. The ingenious thing is that "myDiv" not at all in the current document is, but in the file "somefile".
The second parameter, the load function also data as so-called Key / value pairs passed it.
1
| ) . load ( 'someFile.php' , { 'param' : 'someValue' } ) ; $ ('# SomeElement'). Load ('someFile.php', ('param': 'someValue')); |
This corresponds, however, now more like the normal Ajax request. The one or more key / value pairs are passed to the php script as a post parameter. Of course, one loses the advantage of the previous example to other HTML elements from a script to get DOM simple. But if you request a single direct without any further processing would result in an element of the insert, which is a very easy and comfortable option.
The next part will then progressed to other variants such as get jQuery Ajax, getJSON, etc. go.
Recent Comments