PHP tutorial network to provide
how to learn Ajax how to use get and post and analog Ajax, please pay attention to the Ajax instance tutorial column
learn the three ways that Ajax must know. > two, PHP AJAX implements no refresh page
three, analog PHP AJAX implementation without refresh page
today only share PHP AJAX with GET mode to realize no refresh page
1. initialization. A function that initializes the Ajax:
[code].lt; script.gt;
/**
* initialization of a xmlhttp object
*/
function InitAjax. T (.Quot; Microsoft.XMLHTTP.quot;);
catch (E) {
ajax = false;
}
}
execute a Get request, add the data that we need to get /show.php? Id=1, how to use ajax get method to realize the data without refresh show.php? Id=1.
there is a link:.Lt; a; You can let no refresh execute show.php to get the corresponding content when id=1 and then display it in a div layer with innerHTML to be
[code] < a href=.quot; #.quot; onClick=.quot; 1 Do not show:
[code] < div id=.quot; show_news.quot; > /div > [/code]
and construct the corresponding JavaScript function:
[code]
.lt; Turn false;
}
var url =.Quot; /show.php? Id=.quot; />ajax.open (.Quot; GET.quot; URL, true);
show.innerHTML = ajax.responseText if they do not understand the Ajax status code;
}
}
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / The corresponding layer below will display the contents and no refresh on the page. Of course, we omitted the show.php file on it. We just assumed that the show.php file existed and was able to work normally from the database to extract the news of the ID 1.
this way is adapted to any element in the page, including forms, and so on. In application, the operation of the form is much more, for the form, more is used in the POST mode.