JQuery simple Ajax call example and jqueryajax example
JQuery is really convenient. Here is a simple Ajax call:
Create a simple html file:
<! Doctype html>
Now, click the button to see the effect.
Of course, there are many control items for jQuery Ajax calls. Here we demonstrate simple calls.
Pay attention to your own jquery reference path.
Let's look at an example of calling the background:
<! Doctype html>
Background code:
<?php $msg='Hello,'.$_POST['name'].',your age is '.$_POST['age'].'!'; echo $msg;
Now we can get data from the background!
Of course, we can also call Ajax like this:
<! Doctype html>
Note,
Success: function (data)
The data parameter in can be changed to another name, such as success: function (msg), and msg (data) is the returned data. This is the callback function parameter, not
Data: "name = garfield & age = 18"
The data parameter in the Ajax call.