ASP tutorial. NET jquery Ajax return value and output
This article is about a jquery Ajax return value How to get the ASP.net tutorial to receive and output the instance code.
<script language= "Web Effects" src= "Js/jquery-1.3.2.min.js" ></script>
<script type= "Text/javascript" >
var url = "Webform2.aspx";
var obj = new Object ();
obj["BH"] = "1";
Obj["XM"] = "Liu";
var aa = ajaxrequest (URL, obj);
function ajaxrequest (URL, obj) {
var entity = null;
$.ajax ({
ContentType: "Application/json",
Url:url,
Type: ' Post ',
Async:false,
DataType: ' JSON ',
Data:obj,
Success:function (data) {
if (data!= null) {
entity = data;
}
},
Error:function () {
Alert ("An error!") ");
}
});
return entity;
}
</script>
ASPX receives data
Response.Write ("{name: ' abc '}");
Success:function (data) {
Alert (data)//output {name: ' abc '}
var o = eval ("(+ Data +)");
alert (o.name);//Output ABC
}