代码如下
js:
.ashx:
data中的数据一直是undifined
该怎么解决?
已解决。。忘记返回值了。。一般处理程序加上context.Response.Write(Login(name, pw));就好了
你试试在回调方法里面打印,看看有没有值。如果没有的话就是确实没有从服务器返回值,如果有值,那建议你把post方式改成$.ajax();形式
var b 写post 里面,外面不好使
function(data){
alert(data);
}
这样就行
你在里面直接data试试,你这个可能是由于同步和异步问题造成的,你给post设置一个async:false(设置这个参数为false,可以保证post请求完成后,才继续执行下面的代码),试试,
在$.post用json试试$.post(url,data,function(data){ alert(data);},'json')
试试指定返回数据格式为"json"
$.post("test.php", { "func": "getNameAndTime" },
function(data){
alert(data.name); // John
console.log(data.time); // 2pm
}, "json");