How to use AJAX in WordPress theme

Now these days AJAX become more popular to create dynamic, user-friendly and responsive websites. AJAX is the technology to send and receive data with reload the page in web browser. One of the great example you can see in Google DOCS, that saving your work in few minutes or you can see instant image upload.

What is AJAX?

If still you are not familiar with AJAX then we suggest you to read about AJAX on Wikipedia. Or you can use AJAX with jQuery, one of the most popular JavaScript Library. AJAX is the combination of HTML, CSS and JavaScript code that helped you to send data to the particular file and receive the response from that file without refreshing the browser or page.
Read More

Ajax based contact form

If you want to make an application which respond quickly without refreshing the page then, JSON(JavaScript Object Notation) and AJAX(Asynchronous JavaScript And XML) combination is great to achieve that. In this post we are making a simple Ajax based contact form which respond the result in JSON format that we want, and with the help of jquery we display the JSON data.

Through AJAX we are sending the contact form data to a php file(submit_contact_form.php) and then getting the response as an JSON format, but as you see that in my php file, i didn’t used the ‘json_encode()’ function, the reason behind this is ‘json_encode()’ require PHP5 or above. But in this example i created the same format with the help of ‘echo’ that will work for me in PHP4.4.9 too.

So, Here is the HTML structure for the contact form, just put this structure inside the body tag.

Read More

Ajax based instant image upload

Image upload is simple to just select an image and click on the upload button that’s it. But it will be more effective when the selected image upload instanly means with out click on any upload button and you will see also the preview of that uploaded image.

All this will be more easy with ajax (asynchronous javaScript and xml) request. In this example we will use the ajax form plugin. I really thanks for this plugin because with the help of this plugin it will be more easy to make an ajax based instant image upload script.

Instant Image Upload

Read More