ajax没有工作onreadystatechange功能 [英] ajax not working onreadystatechange function

查看:70
本文介绍了ajax没有工作onreadystatechange功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var xmlhttp;
		if(window.XMLHttpRequest)
		{
			xmlhttp=new XMLHttpRequest();
		}
		xmlhttp.onreadystatechange=function()
		{
			if(xmlhttp.readyState==4 && xmlhttp.readyState==200)
			{
				alert(xmlhttp.responseText);
			}
		}
		xmlhttp.open(GET,"signupin.php",true);
		xmlhttp.send();





signupin.php



echo(你好);



代码应该提醒你好



问题出在哪里?



signupin.php

echo("hello");

the code should alert hello

where is the problem?

推荐答案

不要去寻找传统的Ajax请求。试试jquery ajax来完成这个任务。



包含来自 JQuery 网站的项目中的jquery.js库

然后在您使用过的页面上引用它

现在拨打下面的ajax电话



Don't go for conventional Ajax request.Try jquery ajax to accomplish this task.

include jquery.js library in your project from JQuery site
Then reference it on your used page
Now make an ajax call as below


document )。ready( function (){
(document).ready(function(){


。 ajax( function (){
url: signupin.php
mType: GET
异步:< span class =code-string> true
成功: function (){
alert( Hello);
}
});
});
.ajax(function(){ url:"signupin.php", mType:"GET", async:"true", success:function(){ alert("Hello"); } }); });



如需参考,请查看以下链接中的jquery文档

ajax

看到魔法!希望这对你有帮助。


For reference please have a look at jquery documentation from below link
ajax call using JQuery
See the magic!Hope this will help you.


这篇关于ajax没有工作onreadystatechange功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆