new H_ajax(){Mixed}
ajax.js, line 28
Returns:
| Type | Description |
|---|---|
| Mixed | content depending module return |
Example
basic usage :
automaticaly used by forms generated by helPHP server libs (h::form), you can create an ajax request like this:
---------------------------------------------------------------
let settings = {}; //our array of params
settings.url = ''; // the url to send you ajax request
settings.data = { //the data key/pairs you want to send
'param1':'value1' ,
'param2':'value2' ,
'param3':'value3',
'action':'moduleaction'
};
settings.success = (res) => { //what to do with the result, set a callback etc...
do something with res;
};
settings.error = (err) => { //what to do in case of error...
do something with err;
debugger;
};
h.a.send(settings); //we send our request
-----------------------------------------------------------------
Methods
-
compute_progress()
ajax.js, line 406 -
Computes the global progress for all running AJAX streams.
-
form_to_obj(form){Object}
ajax.js, line 100 -
Converts all inputs in a form to a JSON object.
Name Type Description formHTMLFormElement The form element to serialize. Returns:
Type Description Object The serialized form data as an object. -
get_sender(){H_ajax_sender}
ajax.js, line 284 -
Gets the first available XHR sender or creates a new one.
Returns:
Type Description H_ajax_sender The sender instance. -
queue(sender)
ajax.js, line 344 -
Queues a sender for later execution.
Name Type Description senderH_ajax_sender The sender to queue. -
readable_file_size(size){string}
ajax.js, line 145 -
Converts a raw byte size into a human-readable string.
Name Type Description sizenumber The size in bytes. Returns:
Type Description string Human-readable file size. -
send(settings, delay, queue){H_ajax_sender|boolean}
ajax.js, line 319 -
Sends data according to the provided settings.
Name Type Description settingsObject AJAX settings. delaynumber Optional delay before sending. queueboolean Whether to queue the request. Returns:
Type Description H_ajax_sender | boolean The sender or false if queued. -
staticH_ajax.check_file_data(dom_element){boolean}
ajax.js, line 161 -
Checks if the file inputs respect the server limitations.
Name Type Description dom_elementHTMLElement | FormData The DOM element or FormData to check. Returns:
Type Description boolean True if valid, false otherwise. -
staticH_ajax.sleep(ms){Promise.<void>}
ajax.js, line 277 -
Sleep utility function (async). can be used to async / wait,
Name Type Description msnumber Milliseconds to sleep. Returns:
Type Description Promise.<void> Promise that resolves after the delay. Example
await h.a.sleep(5000); or await H_anim.sleep(5000); -
staticH_ajax.submit_on_change(selectDomElement){boolean}
ajax.js, line 129 -
Submits a form when a select element changes.
Name Type Description selectDomElementHTMLElement The select element. Returns:
Type Description boolean True if submitted, false otherwise. -
staticH_ajax.tinymce_image_upload_handler(blobInfo, success, failure)
ajax.js, line 228 -
TinyMCE image upload handler for AJAX image uploads. called by Tinymce.php lib optionnaly
Name Type Description blobInfoObject TinyMCE blobInfo object. successfunction Success callback. failurefunction Failure callback.