Jquery+ajax+asp.net method to get the JSON value _jquery

Source: Internet
Author: User

The example in this article describes how jquery+ajax+asp.net gets the JSON value. Share to everyone for your reference, specific as follows:

 
Ajax Post Text function SaveData (tempid) {var tid = $ (' #hidtemplate '). attr (' value ');
  var desc = $ ("#contentdiv"). html ();
  var num_iid = $ ("#num_iidArr"). attr (' value '); var Num_iid2 = $ ("#num_iidArr001"). attr (' value ');
  Publish page var Topsvalue = $ ("#tops"). attr (' value '); if (num_iid!= "" && num_iid2!= "") {$.ajax ({url: ' tabbaohandler.ashx ', type: ' POST ', dat A: ' type=3&num_iid= ' + num_iid2 + ' &tid= ' + tid + ' &desc= ' + desc + ' &top_session= ' + topsvalue, dat Atype: ' Text ', timeout:20000, Cache:false,//async:false,//Sync beforesend:loadfunction,//Load execution Method Error:erryfunction,//Error execution method success:succfunction//Successful Execution method}) function Loadfunction () {Sho
    Wload ("Running ..."); function Erryfunction () {$ ("#contentdiv"). HTML ("<p style=\" padding:5px\ ">sorry, submit failure </p>");
    Closeload (); } function Succfunction (TT) {closeload ();
    $ ("#contentdiv"). Show (). HTML (TT);
  } else {alert ("Please select Back to operate");

 }
}
 using System;//new using System.Web.Script.Serialization; using
System.Collections.Generic; Public partial class AjaxQuery:System.Web.UI.Page {protected void Page_Load (object sender, EventArgs e) {if (!)
      IsPostBack) {list<student> List = new list<student> ();
      Student C = new Student ();
      C.name = "John";
      C.age = 23;
      C.sex = "male"; List.
      ADD (c);
      Student cc = new Student (); Cc.
      Name = "Dick"; Cc.
      Age = 25; Cc.
      Sex = "male"; List.
      ADD (CC);
      Student CCC = new Student (); Ccc.
      Name = "Li Ling"; Ccc.
      Age = 25; Ccc.
      Sex = "female"; List.
      ADD (CCC);
      Response.ContentType = "Application/json"; Response.Write (New JavaScriptSerializer ().
    Serialize (list));////This is critical, otherwise error response.end ();
    struct Student {public string Name;
    public int age;
  public string Sex; }
}

PS: Here we recommend a number of this site JSON format data online operation tools for everyone to use, I believe that in future development can be used:

Online JSON code inspection, inspection, landscaping, formatting tools:
Http://tools.jb51.net/code/json

Online Xml/json Mutual Conversion tool:
Http://tools.jb51.net/code/xmljson

C Language Style/html/css/json code formatting landscaping Tools:
Http://tools.jb51.net/code/ccode_html_css_json

JSON code online Format/beautify/compress/edit/Convert tools:
Http://tools.jb51.net/code/jsoncodeformat

More interested readers of jquery-related content can view the site's topics: A summary of Ajax usage in jquery, a summary of jquery table (table) operations tips, a summary of jquery drag-and-drop effects and techniques, a summary of jquery extension techniques, jquery Common Classic Effects Summary "jquery animation and special effects usage Summary", "jquery selector usage Summary" and "jquery common Plug-ins and Usage summary"

I hope this article will help you with the jquery program design.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.