Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery AJAX Call Returns null Response Time to Time
    primarykey
    data
    text
    <p>I have a link on my page which creates an AJAX call the page itself and returns a value. Response generated by server, which created successfully, becames empty or sometimes error function of the AJAX. I tried almost everything and couldn't come up with a solution.</p> <p>Here is my AJAX function:</p> <pre><code>var Ajax = { AjaxCall: function (uri, jsonData, callBack, postParams) { $.ajax({ cache: false, type: "POST", url: uri + ((uri.indexOf("?") &gt; -1) ? "&amp;" : "?") + "rand=" + new Date().format("ssmmHHddMMyyyy"), data: JSON.stringify(jsonData), contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { Ajax.AjaxCall_CallBack(msg, callBack, postParams); }, error: function (msg) { Ajax.AjaxCall_CallBack_Error(msg); } }); }, AjaxCall_CallBack: function (msg, callBack, postParams) { callBack(msg, postParams); }, AjaxCall_CallBack_Error: function (msg) { alert(msg.responseText); } } </code></pre> <p>and the function makes the AJAX call</p> <pre><code>Ajax.AjaxCall('dummypage.aspx?ajax=6&amp;edit=1&amp;uID=' + uID, null, callback_func, [uID, 'Test Text', 0]) </code></pre> <p>The value generated from server is something like this:</p> <pre><code>Table tbl; TableRow tr; TableCell tc; Label lbl; DropDownList ddl; tbl = new Table(); tr = new TableRow(); tc = new TableCell(); lbl = new Label(); lbl.Text = "Choose one" tc.Controls.Add(lbl); tr.Cells.Add(tc); tc = new TableCell(); ddl = new DropDownList(); ddl.Items.Add("Choose", "-1")); ddl.Items.Add("First", "1"); ddl.Items.Add("Second", "2"); ddl.ID = "ddlContentType"; tc.Controls.Add(ddl); tr.Cells.Add(tc); tbl.Rows.Add(tr); StringBuilder sb = new StringBuilder(); StringWriter tw = new StringWriter(sb); HtmlTextWriter hw = new HtmlTextWriter(tw); tbl.RenderControl(hw); string renderedValue = sb.ToString(); hw.Close(); return HttpUtility.JavaScriptStringEncode(renderedValue, true); </code></pre> <p>I don't understand why exact same structure on the same page which has the same procedure works but not this?</p> <p>Thanks in advance.</p>
    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