<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if (window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
//[{Name:"张可",Class:4},{Name:"李贵",Class:5}]
function doJSON()
{
createXMLHttpRequest();
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.open("post","dojson.aspx",true);
xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencode");
xmlHttp.send({Name:"张可",Class:4},{Name:"李贵",Class:5});
}
function handleStateChange()
{
if(xmlHttp.readyState == 4)
{
if(xmlHttp.status == 200)
{
alert("is ok!!!");
}
}
}
</script>
c#
protected void Page_Load(object sender, EventArgs e)
{
byte[] b = new byte[this.Request.InputStream.Length];
this.Request.InputStream.Read(b, 0, b.Length);
string s = System.Text.Encoding.Default.GetString(b);
student s1 = (student)JavaScriptConvert.DeserializeObject(s, typeof(student));
}
public class student
{
public string Name
{
get{;}
set{;}
}
public string Class
{
get{;}
set{;}
}
};
所需要组件下载http://james.newtonking.com/
责任编辑:小草