Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do you do use cfajaxproxy with setSyncMode()?

New Here ,
Apr 24, 2009 Apr 24, 2009

I found lots of examples using asynchronously, but I can't find any examples using synchronously?  Does anyone know how to do that?

Using the adobe example below, how would you change from asynchronously to synchronously? I added in setSyncMode(), but doesn't seem to work.

            // Use an asynchronous call to get the employees for the 
            // drop-down employee list from the ColdFusion server.
            var getEmployees = function(){
                // Create an instance of the proxy.
                var e = new emp();
                     e.setSyncMode(); // I added here
                // If you set a callback handler for the proxy, the proxy's calls
                // are asynchronous.
                e.setCallbackHandler(populateEmployees);
                e.setErrorHandler(myErrorHandler);
            // The proxy getEmployees function represents the CFC
            // getEmployees function.
                e.getEmployees();
            }

Thanks,

Richard

1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2009 Sep 11, 2009
LATEST

If anybody is still interested in this here is  my javascript code that makes the ajax call:

function someFunction()

{

//make the ajax call to delete the item
var delRes = deleteTheItem(itemNum);

if (delRes == true)
{
  //call the function to decrement the num of items value and update the totals or do whatever
  }
else
{
//alert user delete not successfully
  alert("You cannot delete this item ! This Item is being used for Receiving. You must first delete this item from receiving . ");
}


}//end function

//AJAX call to delete the item from the database
function deleteTheItem(iNo)
{

    var prNum = document.frmPurchaseRequest.PRNumber.value;
  var n = new myObj();
n.setSyncMode();  // this makes a synchronous call where nothing will happen until the call returns


//actual call to the the cfc, the result is either true or false -
var theRes = n.delItem(prNum,iNo);   // the key is to capture the result in a variable
return theRes;
}

The above code works for me. It is important that you do not use the setCallBackHandler function cause it sets the synchronization mode to asychrononous.

hope this helps!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources