Test User Test User - 1 year ago 84
Ajax Question

Make ASP.NET AJAX function call synchronous

I have an ASP.NET form that calls a web service using ASP.NET AJAX. How do I make the call synchronous?

// test.aspx

<script type="text/javascript">
function GetDescription(){
var code = document.getElementById("<%=txtCode.ClientID%>").value;
var description =
code, onSuccessGetDescription, null, null);
return false;

function OnSuccessGetDescription(result){
var txtDescription =
<script type="text/javascript">
$(document).ready(//function () {

$('#<%=cmdSave.ClientID%>').click(function (e) {
if (Page_ClientValidate()){
// Populate jQuery.UI dialog box with code and description
// and then


<asp:TextBox ID="txtCode" />
<asp:TextBox ID="txtDescription" />
<asp:Button ID="cmdSave" />

// test.aspx.cs

protected void Page_Load(object sender, EventArgs e)
txtCode.Attributes["onblur"] = "GetDescription();";

The answers to this question that I have seen say that I should set the async attribute to false, but I don't see how to do that here.
ASP.Net Ajax - PageMethods Synchronous call and retrieval of results says that it can't be done. I am trying to get a second opinion.

If I can't make the call synchronous, would it be legal to make GetTransaction poll until the OnSuccess function returns? What would be an efficient (i.e. not CPU-intensive) way to do that?

Answer Source

JQuery Asynchronous

url: 'http://example.com/catalog/create/' + targetNode.id + '?name=' + encode(to.inp[0].value),
success: function (result) {
   if (result.isOk == false) alert(result.message);
    async: false
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download