Ajax:
General handler (Data Interface): ASHX
Passing Data across languages:
Xml:
The structure is not clear
Large code size
It's more trouble finding.
Non-object-oriented structure
Json:
Clear structure
Relatively small amount of code
Object-oriented processing parsing method, finding data is simple
Key-value pairs
{"Key1": "Value", "Key2": "Value"}
JSON for multiple objects
[{"Key1": "Value", "Key2": "Value"},{"Key1": "Value", "Key2": "Value"},{"Key1": "Value", "Key2": "Value"}]
After quoting jquery
$.ajax ({URL:"ajax/***.ashx", data: {"Key1":"value","Key2":"value"}, type:"Post", DataType:"JSON", Success:function (data) {}});
ASHX file
1 stringc = Context. request["Code"];2List<china> ulist =NewChinadata (). Select (c);3 4 stringJSON ="[";5 6 7 intCount =0;8 foreach(China uinchulist)9 {Ten if(Count >0) One { AJSON + =","; - } - theJSON + ="{\ "areacode\": \ ""+ U.areacode +"\ ", \" areaname\ ": \""+ U.areaname +"\"}"; -count++; - } - +JSON + ="]"; - + context. Response.Write (JSON); AContext. Response.End ();
ashx File
.
AJAX--2017 Year January 15