Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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!