Ajax Call (value-sent) generic handler (. ashx)

Source: Internet
Author: User

Problem: Accumulating in the general handler (. ashx) [index=' B '] value difficulty: Foreground gets JSON value background resolution resolved:#region the value of the index=b exists in the JSON objectfunctionAjaxgetsum() { var arr = [];$("input[index= ' B ']"). each (function() {  var arrobject = {};  var TempVal = $ (This). Val ();  if (!$.gstr.isempty (TempVal)) { //The company's own encapsulated JS $.gstr.isempty (ST) to determine whether St is empty, return true/false  arrobject[ "invalue"] = TempVal;   Arr.push (arrobject);   } });  var jsonstring = json.stringify (arr); //Convert to JSON-type string $.post ("Handlersum.ashx", {jsonvar:jsonstring}, function (data) {  alert (data); })}//#endregion               






Using System;Using System.Collections.Generic;Using System.Linq;Using System.Web;Using Newtonsoft.json;Using Newtonsoft.Json.Linq;Using Newtonsoft.Json.Converters;Namespace train_first.ajax_rpc{ ///<summary> Summary description of Handlersum ///</summary> PublicClass Handlersum:ihttphandler{  Publicvoid ProcessRequest (HttpContext context) {  Context. Response.ContentType ="Text/plain";   string ss = Context. request.form["Jsonvar"];Get an array of lessons JSON strings passed by the foreground  Jarray JavaScript = (Jarray) jsonconvert.deserializeobject (ss);An array of JSON strings obtained by deserialization   String stringsum ="";   for (int i =0; I < JavaScript. Count; i++)  {   Jobject obj = (jobject) javascript[i];    String outvalue = obj["Invalue"]. ToString ();Converts an array of deserialized JSON strings into objects   Stringsum + = Outvalue;  }   context. Response.Write (Stringsum);  }  public bool isreusable  {   get   {     return false;  } }}}  /span>                

Ajax Call (value-sent) generic handler (. ashx)

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.