ajax+php instance data invocation and asynchronous transmission
function Init_ajax ()
{
var Ajax=false;
try{
Ajax = new ActiveXObject ("Msxml2.xmlhttp");
}catch (e) {
try {
Ajax = new ActiveXObject ("Microsoft.XMLHTTP");
}catch (E) {
Ajax = FALSE;
}
}
if (!ajax && typeof xmlhttprequest!= ' undefined ') {
Ajax = new XMLHttpRequest ();
}
return Ajax;
}
function Get_menu ()
{
var url = "Ajax_pages.php?act=menus";
var show = document.getElementById ("menu");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function Film_query () {
var div_form = document.getElementById ("main");
var post_form = document.queryfrm;
var name = Post_form.query.value;
if (name = = "") {
return 0;
}
var posturl = "Ajax_pages.php?act=media";
var senddata = "query=" + name;
Div_form. InnerHTML = "in query ... Please later ... ";
var ajax = Init_ajax ();
Ajax.open ("POST", PostURL, True);
Ajax.setrequestheader ("Content-type", "application/x-www-form-urlencoded; Charset=utf-8 ");
Ajax.send (SendData);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
div_form.innerhtml = Ajax.responsetext;
}
}
}
function Top10 () {
var url = "Ajax_pages.php?act=newfilms";
var show = document.getElementById ("main");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function medias (ID) {
var url = "Ajax_pages.php?act=media&type=" +ID;
var show = document.getElementById ("main");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function Medias_page (id,page) {
var url = "ajax_pages.php?act=media&type=" +id+ "&page=" +page;
var show = document.getElementById ("main");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function logout ()
{
var url = "Ajax_pages.php?act=logout";
var show = document.getElementById ("main");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function Qvod_play (URL) {
var url = "Ajax_pages.php?act=player&player=0&id=" +url;
var show = document.getElementById ("players");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function Get_foot ()
{
var url = "Ajax_pages.php?act=foot";
var show = document.getElementById ("foot");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function Postnews ()
{
var url = "sender.php";
var show = document.getElementById ("main");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function Login_post () {
var div_form = document.getElementById ("LoginPage");
var post_form = Document.loginform;
var account = Post_form.account.value;
var password = post_form.password.value;
var posturl = "Ajax_pages.php?act=login";
var senddata = "Account=" + account + "&password=" + password + "&login=loginpost";
Div_form. InnerHTML = "Submit in ... Please later ... ";
var ajax = Init_ajax ();
Ajax.open ("POST", PostURL, True);
Ajax.setrequestheader ("Content-type", "application/x-www-form-urlencoded; Charset=utf-8 ");
Ajax.send (SendData);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
div_form.innerhtml = Ajax.responsetext;
}
}
}
function Login ()
{
var url = "Ajax_pages.php?act=login";
var show = document.getElementById ("main");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function read_news (ID)
{
var url = "Ajax_pages.php?act=readnews&id=" +ID;
var show = document.getElementById ("main");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function Newslist (ID) {
var url = "Ajax_pages.php?act=newslist&id=" +ID;
var show = document.getElementById ("main");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function Divhide (name) {
var show = document.getElementById (name);
show.innerhtml = "";
}
function Register ()
{
var url = "Ajax_pages.php?act=register";
var show = document.getElementById ("main");
show.innerhtml = "in data transfer .... Please wait a moment ... ";
var ajax = Init_ajax ();
Ajax.open ("Get", url, True);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
show.innerhtml = Ajax.responsetext;
}
}
Ajax.send (NULL);
}
function Register_check () {
var reg_form = Document.regform;
var account = Reg_form.account.value;
var password = reg_form.password.value;
var idcard = Reg_form.idcard.value;
var email = reg_form.email.value;
var password2 = Reg_form.password2.value;
var div_form = document.getElementById ("Pwdchk");
Reg_form.registers.style.display= "None";
if (account!= ' && password!= ' && idcard!= ' && email!= ' && password2!= ') {
if (password!= password2) {
div_form.innerhtml = "<font color=red> two times password input is different, please check!" </font> ";
}else{
Div_form.style.display= "None";
Reg_form.registers.style.display= "";
}
}
}
function Textareaadd () {
var post_form = document. Postnews;
Post_form.newstext.rows + 1;
}
function Textareadrop () {
var post_form = document. Postnews;
if (post_form.newstext.rows>1) {
Post_form.newstext.rows-= 1;
}
}
function Postnewss () {
var div_form = document.getElementById ("Newpost");
var post_form = document. Postnews;
var channel = Post_form.postto.value;
var title = Post_form.title.value;
var postt = Post_form.newstext.value;
var posturl = "sender.php";
var senddata = "tit=" + title + "&nt=" + Postt + "&cnid=" + Channel + "&postbutton=postnews";
Div_form. InnerHTML = "Submit in ... Please later ... ";
var ajax = Init_ajax ();
Ajax.open ("POST", PostURL, True);
Ajax.setrequestheader ("Content-type", "application/x-www-form-urlencoded; Charset=utf-8 ");
Ajax.send (SendData);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
div_form.innerhtml = Ajax.responsetext;
}
}
}
function Register_post () {
var div_form = document.getElementById ("register");
var reg_form = Document.regform;
var account = Reg_form.account.value;
var password = reg_form.password.value;
var idcard = Reg_form.idcard.value;
var email = reg_form.email.value;
var password2 = Reg_form.password2.value;
var posturl = "Ajax_pages.php?act=register&post=post";
var senddata = "Account=" + account + "&password=" + password + "&idcard=" + Idcard + "&email=" + email + "&am" P;password2= "+ password2;
Div_form. InnerHTML = "in registration ... Please later ... ";
var ajax = Init_ajax ();
Ajax.open ("POST", PostURL, True);
Ajax.setrequestheader ("Content-type", "application/x-www-form-urlencoded; Charset=utf-8 ");
Ajax.send (SendData);
Ajax.onreadystatechange = function () {
if (ajax.readystate = = 4 && ajax.status = 200) {
div_form.innerhtml = Ajax.responsetext;
}
}
}