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
}).responseText;
// We put the returned text into the Container.
$('#container').html(html);
}
Code language: JavaScript (javascript)
Thanks for a simple example!!
Glad it helped 😉