JQuery load()We can fetch the content returned by any URL or page by using load(). Here we have one display layer with id =d1, to the same layer we will load with a file loat-text.php.
Inside load-text.php file we have only one line of text
Passing variable while loading the file using GET method![]() We can pass variable to our file and then read them back. Here we have used in PHP file load-text1.php file to collect the parameter and return the same. Now we will use JQuery code to load the url with parameter on Button Click. HTML
JQuery
encodeURIComponent()When we have blank space , / ? : @ & = + $ # as part of the string then we can use encodeURIComponent() to encode the data before sending in query string.
Our backend file load-text1.php code is here
POST methodIn the above code it has used GET method to post data to backend script, to use POST method we have to use object to post data. We will create object by reading two text boxes as first name and last name. We will use them to post data to backend , you can read more on how to read data entered in a text box.We have used load-text2.php file to receive data from POST method. Then same data is retuned with a welcome message.
First Name Last Name HTML
JQuery
Our Backend script load-text2.php file code is here
Using Callback functionWhile loading the page we can use callback function to check status of the script. HereHTML
JQuery
Using callback function we can display messages to the user about the backend process. Once the user click a button the process starts, then we will show a message telling user to wait. At the backed script we will create a delay of 5 seconds. After the delay period we will show process complete message to user by using the callback function.
Here is the JQuery Script.
Class not recognized for handling events in main pageIf any class is used in loaded page, then to apply any event to this class we have to use like this.$('#d2').on('click', ".my_class", function () { // your script here //var b_card_id=this.id; // read the id of clicked class })Here my_class is class used in loaded page which gets loaded after an event. #d2 is the id of the Div to display content which is loaded. Application using loadWe will develop one PHP script where we will display name of the students from a MySQL table ( or array ). On click of the name of the student we can collect other details like Class, Mark from the table.![]() |
Most Popular JQuery Scripts | |
1 | Two dependant list boxes |
2 | Calendar with Date Selection |
3 | Data change by Slider |
4 | Show & Hide element |