I like to bind to the outsystems ajaxsend event. Is there a way? The code below does not seem work.

Best regards,
Niek Oosterbeek.

$(document).bind("ajaxSend", function(){
   $('.SaveAllButton').attr("disabled","disabled");
 });

For 3 years you and likely others have been waiting for an answer.

I ran into the same issue and searched the web for help finding your thread, so I'll post here the solution I eventually discovered through the javascript debugger in the browser. OutSystems uses their own internal copy of jQuery, so the events are fired as part of that entity. That means putting event handlers on the main $(document) won't work, you have to put them on the internal jQuery object OS is using. You do that like this:

outsystems.internal.$( document ).ajaxComplete(function() {
      console.log('outsystems.internal.$( document ).ajaxComplete(); ran.');
});

outsystems.internal.$( document ).ajaxSend(function() {
      console.log('outsystems.internal.$( document ).ajaxSend(); ran.');
});


There are more events and documentation on these here:

https://api.jquery.com/category/ajax/global-ajax-event-handlers/


Hi PJ M,

Nice to read that you have been able to come up with a solution.
However when I try to add the function as mentioned in your comment I get the message that outsystems.internal is for internal use.
Can you tell me where you have been able to add this?

Kind regards,
Bart

Hi Bart, 

Yes, you are correct, that can be an issue depending on how you get your javascript into the page. I found that OutSystems just looks for the string outsystems.internal in your code, so if you just separate it with a plus, then OutSystems can't find it anymore.

So, if your string is like this:

"//something here

...outsystems.internal...

//more code"

Then change it to be like this

"//something here

...outs" + "ystems.internal...

//more code"

Then Outsystems won't see that string in your code to throw an error. Of course if OutSystems stops using jQuery in that way, then your code may break, which is why they are trying to keep us from using it, but unfortunately, we need to use it to make it work right, so there you have it.

Hi Niek,

Isn't this what you're looking for?

Cheers

PJ M wrote:

Hi Bart, 

Yes, you are correct, that can be an issue depending on how you get your javascript into the page. I found that OutSystems just looks for the string outsystems.internal in your code, so if you just separate it with a plus, then OutSystems can't find it anymore.

So, if your string is like this:

"//something here

...outsystems.internal...

//more code"

Then change it to be like this

"//something here

...outs" + "ystems.internal...

//more code"

Then Outsystems won't see that string in your code to throw an error. Of course if OutSystems stops using jQuery in that way, then your code may break, which is why they are trying to keep us from using it, but unfortunately, we need to use it to make it work right, so there you have it.

Hi PJ M

I try to use your way like this:

"outs" + "ystems.internal".$(document).ajaxSuccess(
    function(){
        cosole.log('ajax success');
    }
);

error information:

Uncaught  TypeError: "ystems.internal".$ is not a function

please tell me the right way.

Thanks a lot.

and some people said use this way:

osAjaxBackend.BindAfterAjaxRequest(yourCallBack);

but This is an unsupported  and undocumented way.

If I use the above method, will it have an impact on the system?

Thanks again.


Best regards,

Wouter.