Cfajaxproxy in asynchronous mode

Hi,

The documentation isn’t too clear if cfajaxproxy default mode is “snyc” or “async”.
I need to run it in asynchronous mode.

To do so, I specify the setAsyncMode(), see code below but Chrome still complained about

"[Deprecation] Synchronous XMLHttpRequest...".

Not sure if it’s browser cache though I cleared it
or
my syntax of specifying setAsyncMode() is incorrect. Does it have something like
setAsyncMode(true) or setAsyncMode(1)?
or something else

Thanks.

/* js for calling a cfc function to submit form to it and have it save data, and to do so in  asynchronous mode */

var id = 'SD-283-SS';

var d = new JSsavedata();

// Use an asynchronous call
d.setAsyncMode();

// do a call back
d.setCallbackHandler(rtn(id));

// send data
d.setForm('formid');
d.setHTTPMethod('POST');

// cfc savedata function	
d.savedata();


// call back routine
var rtn = function () {
	// do something here
     // use jQuery to reload a DIV
     $("#bottomNav").load("activity1.cfm?id="+id);

}

The default mode should be ASync…
Sync seems to be frowned upon now and I must admit I preferred sync.
It means with async that you don’t get your result straight away and the next line of codes goes on ahead.
I think if you don’t set syncmode then it will work in chrome…
Looks like chrome is dropping the ability for sync.
You are already using jquery so it would be just as quick to change from cfajax proxy if you wished.

I still prefer cfajax I must admit.

Remove the setstnc line and try again?

I agree Chrome is becoming obnoxious with “[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience.” because it does not think of use case. If it’s a public website or web application with potentially millions of users then “sync” call would be detrimental but if it’s for a custom app with limited number of users and such function would be called only a few times a day then “sync” would not be detrimental. What presumptuous arss they are now!

yip… as soon as we get things working, somebody tells is they are bad practice.

Well this would be very bad user experience as a synchronous ajax call would freeze the ui until it returns. The whole point is that it can happen in the background and the user can keep doing things with the ui (mouse overs etc).

First of all, by ajax itself, it’s “async”, ajax (Asynchronous JavaScript And XML), so, there should not even be any need to use setAsyncMode() to set it in “async” mode if cfajaxproxy’s default is “async”, since I got the Chrome’s imposing msg, I thought maybe cfajaxproxy’s default is “sync”, thus, my attempt to add the setAsyncMode() command.

What’s your specific suggestion other than generic comment?

How are you creating all of this? You haven’t show the code that creates the component? Is the code you have show the javacript?

// do a call back
d.setCallbackHandler(rtn(id));

I did a quick test and here is your error, you don’t call a function when you are setting the callback handler, you pass in the function itself. So that the object calls it:

d.setCallbackHandler(rtn);

Also looking at this I can now replicate your error. It’s interesting as if you console.log(d) the created object says it’s asynchronous. but we get the error. I am looking to see if I can find the original cfajaxproxy code anywhere (as it’s just the compressed stuff)

It should be async as you say.

I’d appreciate that.

I had a look in the source code but I cant see where that javascript file (the one from the ajaxloader) is called. I wonder if @micstriit would have an idea?

I know that it was originally written by Andrea Campolongi or at least in part but that was a really long time ago.

To be honest, I very much doubt these tags will get much love since you can easily do this with jQuery or newer libraries now:

$.post("/JSsavedata.cfc?method=savedata", {item:1,item:2}, function(ret){
console.log("This is my call back!", ret)
});

I appreciate the effort, and yeah, most of my new code uses jQuery ajax call as your sample indicated.