Home > Web Front-end > JS Tutorial > $.ajax json data transfer method_jquery

$.ajax json data transfer method_jquery

WBOY
Release: 2016-05-16 18:58:34
Original
1007 people have browsed it

Front Desk

Copy code The code is as follows:




Untitled page





Click

Receive background data

hello




Backstage
Copy code The code is as follows:

protected void Page_Load(object sender, EventArgs e)
{
Hashtable ht = new Hashtable();
string name = Request.Params["name"].ToString();
string birth = Request.Params["birthday"].ToString();
if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(birth))
{
//Response.ContentType = "Application/json";
//Response.Write(CreareJson("this is ok!", 1, name, birth));
ht.Add("info", "Successful");
ht.Add("sta", "status");
ht.Add("name", name) ;
ht.Add("birth", birth);
Response.Write(CreateJsonParams(ht));
}
Response.End();
}
private string CreateJsonParams(Hashtable items)
{
string returnStr = "";
foreach(DictionaryEntry item in items)
{
returnStr = """ item.Key.ToString() "": "" item.Value.ToString() "",";
}
return "{" returnStr.Substring(0,returnStr.Length-1) "}";
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template