Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Cancelling a jQuery Data Service in the before Send Method

All,

I'd like to be able to conditionally execute a data service - based on the results of some Javascript that would run in the 'beforeSend' method of the data service.

Since the Appery jQuery implementation appears to mimic the 'vanilla' jQuery implementation with a very nice UI around it - I've found this in the jQuery docs ....
==========================================================
beforeSend
Type: Function( jqXHR jqXHR, PlainObject settings )
A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request.

============================================================

which states that returning FALSE in the before Send will implement this in jQuery....

so - in the UI builder - where executing a data service - in some before Send Javascript - if I return FALSE from that Javascript --- will it NOT execute my data service?? (I hope) ....

is there another way to accomplish this (other than writing my own jQuery Ajax call....) ??

Thanks!
Bruce
Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Cancelling a jQuery Data Service in the before Send Method

Hello Bruce,

There is no such default implementation. But you can run any service with the plain JS, and control it's call with a custom condition

Return to “Issues”