PHP AJAX implements no refresh page in GET

time:14-04-12 forum:PHP tools and code
  Reproduced from the http://www.update8.com/Program/PHP/25905.html

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;
}
} before we execute any Ajax operation, we must first call the InitAjax () function to instantiate a Ajax object.
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.

prev:The drought in Ji'nan next:The solution to the problem of chaotic c...
post comment
Notice



approved   26 mountain parks all over Ji'nan   The young man insisted on 10 years' ...   Do you remember those "made in Ji'na...   Ji'nan's Daming Lake scenic area is ...   Ji'nan free Scenic Area
rand   Does the check directory exist and t...   PHP filter replacement output digita...   PHP uses $_GET to get processing cod...   Fourteen experiences in programming ...   Using JSON to implement cross domain...
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com