How to build a simple Ajax

How to create a simple Ajax call to an other PHP file

How it works?

We use one HTML file with a simple JavaScript function wich call an Ajax.

The function sends data to the Ajax and the Ajax returns something else.

In my example the ajax just returns some text.

function load_ajax(){

// Retrieving the input value
var my_text = $('#my_text').val();

// Send the Data, using Post, to the Ajax.php file.
html = $.ajax({
data: "my_text="+my_text,
type: "POST",
url: "ajax.php",
async: false

// We put the returned text into the Container.



The whole html file with the form and the JavaScript functions.

Example 15 | CodeGround

Example 15 | CodeGround

Write something:

Click here

Go back and leave a Comment


The PHP wich will return our data has:


Leave a Reply

Add <code> Some Code </code> by using this tags.