using System.Runtime.Serialization.Json;
using System.IO;
using System.Text;
//序列化
public string MySerialize(object o)
{
//序列化
DataContractJsonSerializer json = new DataContractJsonSerializer(o.GetType());
using (MemoryStream stream = new MemoryStream())
{
json.WriteObject(stream, o);
string JsonData = Encoding.UTF8.GetString(stream.ToArray());
return JsonData;
}
}
$.ajax({
type: "GET",
url: "../product/GetProductList",
data: {active:1},
dataType: "json",
success: function (data) {
ProductList=data;
var html = '';
if (data != "") {
for (var i = 0; i < data.length; i++) {
html += "
html += '
html += "
html += "
html += '
html += "
}
$("#ProductList").empty();
$("#ProductList").html(html);
}
}
});
using System.IO;
using System.Web.Script.Serialization;
//反序列化
public List
{
var sr = new StreamReader(Request.InputStream);
var stream = sr.ReadToEnd();
//反序列化
JavaScriptSerializer js = new JavaScriptSerializer();
var List = js.Deserialize>(stream);
return List;
}
$.ajax({
type: "POST",
url: "../order/Pay",
data:JSON.stringify(Orders),
dataType: "json",
success: function (data) {
if (data != "") {
if(data.Code==200)
{
if(hb)
{
window.location.href = '../order/status?NO='+data.NO;
}
else
{
window.location.href = '../order/status?hb=false&NO='+data.NO;
}
}
}
},
error: function () {
alert("网络异常,请稍后再试···");
}
});