一个页面行用下jQuery,但其中Ajax没反应啊。
$(document).ready(function() { jQuery.ajax({ type: "POST",
url: "Handler1.ashx",
datatype: "text",
data: "meth=load",
success: function(msg) {
alert("123");
alert(msg);
}
});
)
把它放在页面加载里面只是为了测试
然后是
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Handler1 : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
} public bool IsReusable
{
get
{
return false;
}
}
}
我想象中应该是页面加载的时候就先弹出 123 然后是Hello World 但是现在什么反应都没有 是为什么啊
$(document).ready(function() { jQuery.ajax({ type: "POST",
url: "Handler1.ashx",
datatype: "text",
data: "meth=load",
success: function(msg) {
alert("123");
alert(msg);
}
});
)
把它放在页面加载里面只是为了测试
然后是
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Handler1 : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
} public bool IsReusable
{
get
{
return false;
}
}
}
我想象中应该是页面加载的时候就先弹出 123 然后是Hello World 但是现在什么反应都没有 是为什么啊
type: "Post",
url: "handler.ashx",
datatype: "text",
// data://
beforeSend: function(XMLHttpRequest) { },
success: function(msg) {
alert("123");
alert(msg);
},
complete: function(XMLHttpRequest, textStatus) {
//dosomething
} });
url: "Handler1.ashx",
datatype: "text",
data: "meth=load",
success: function(msg) {
alert("123");
alert(msg);
}
});
) 不是那样写的,
$(document).ready(function(){
$.ajax({
type:"post",
url:"Handler1.ashx",
data:"name=hello",
success:function(msg){
alert(msg);
},
error:function(errmsg){
alert("出错了"+errmsg);
}
});
})首先你可以单独测试你那个ashx的页面是否是正确的。
//经过测试没问题
//请确定你的Handler1.ashx页面的路径
//或是检查WebService是否正确
//请去掉下面俩句测试
//[WebService(Namespace = "http://tempuri.org/")]
//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] function doAjax_XML()
{
$.ajax({
url:'Ajax/Handler.ashx',
type:'POST',
dataType:'text',
data: "meth=load",
error:function(x){alert(x.status);},
success:function(data){alert(data);}
});
}