1. How jqury uses ajax to call the json data generated by the background asp.net page
2. Simple dom operation of jquery
3. Send this jquery development manual to everyone (please study it slowly)
Preparation work:
First of all, we create a new website (.net2.0 is enough).
1. In our project jquery js file.
2. Create a new htm file and name it dome.htm.
The code is as follows: (The js code in the head area is all the code implemented, with detailed comments)
3. Let’s build another general application (jsonData.ashx)
The code is as follows:
<%@ WebHandler Language="C#" Class="jsonData" %>
using System;
using System.Web;
public class jsonData : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string data = "[{ name:"ants",age:24},{name:"lele",age:23}]";//Constructed json data
//The following two sentences are used to test the query issued by the front desk to this page Character
string querystrname = context.Request.QueryString.GetValues("name")[0];//Get the value of name in the query string
string querystage = context.Request.QueryString.GetValues("age" )[0];//Get the value of age in the query string
context.Response.Write(data);
}
public bool IsReusable {
get {
return false;
}
}
}
I will only say one thing about the above content, that is the $.getJSON method in the front page
$.getJSON(url, params, callback)
Use an HTTP GET to request a JavaScript JSON data
Return value: XMLHttpRequest
Parameters:
url (String): URL address of the loaded page.
params (Map): (optional) Key/value pair parameters sent to the server.
callback (Function): (optional) Function executed when data loading is completed.
Posted below are some pictures of successful operations:
1. Operation results
![JQUERY operation JSON example code_jquery](http://files.jb51.net/upload/2010-2/20100209133704810.jpg)
2 , background debugging data:
![JQUERY operation JSON example code_jquery](http://files.jb51.net/upload/2010-2/20100209133704567.jpg)
Statement: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