Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try to handle the JSON sring using following functions.</p> <pre><code>private string ConvertToJSON(objType obj) { string sJSON = "{"; try { AppendToJSON(ref sJSON, "obj1Name", obj.obj1); AppendToJSON(ref sJSON, "obj2Name", obj.obj2); AppendToJSON(ref sJSON, "obj3Name", obj.obj3); AppendToJSON(ref sJSON, "obj4Name", obj.obj4); return sJSON.Substring(0, sJSON.Length - 1) + "}"; } catch (Exception ex) { return ""; } } private void AppendToJSON(ref string byValJSON, string Name, string Value) { byValJSON = byValJSON + "\"" + Name + "\":\"" + Value + "\","; } </code></pre> <p>And post the string to the server.</p> <pre><code>using System.Web; public class AttributesHandler : IHttpHandler { public void ProcessRequest(System.Web.HttpContext context) { string JSON = null; string timeOut = null; timeOut = System.Web.HttpContext.Current.Server.ScriptTimeout; try { System.Web.HttpContext.Current.Server.ScriptTimeout = 600; System.Web.HttpContext.Current.Response.ContentType = "text/javascript"; System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8; JSON = ConvertToJSON(obj); System.Web.HttpContext.Current.Response.Write(JSON); System.Web.HttpContext.Current.Server.ScriptTimeout = timeOut; } catch (Exception ex) { } } } </code></pre> <p>call Using DotNet code:</p> <pre><code>string Url = ""; Url = "http://xxxxxxxxxxxxxx/AttributesHandler.ashx?cd=xx"; object @out = null; try { Net.WebClient webclient = new Net.WebClient(); webclient.UseDefaultCredentials = true; @out = System.Text.Encoding.ASCII.GetString((webclient.DownloadData(Url))); } catch (Exception ex) { //out = ex.InnerException.ToString } </code></pre> <p>here they will get Response as string only.</p> <p>Using Javascript Ajax.</p> <pre><code>$.ajax({ type: "GET", timeout: 60000, cache: false, dataType: "jsonp", url: "http://xxxxxxxxxxxxxx/AttributesHandler.ashx?cd=xx" success: function (response) { objAttributes = response.Attributes; //in object formate if (objCardAttributes != null) { //can process the objects } __doPostBack('upToolkit',); }, error: function (XMLHttpRequest, textStatus, errorThrown) { var sReturn = "Please close the browser and relaunch "; if (textStatus != null) { sReturn += " Details: (" + textStatus + ")"; } if (errorThrown != null) { sReturn += " Description: (" + errorThrown.Description + ")"; } __doPostBack('upToolkit', sReturn); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload