The Ecstore JS Framework uses MooTools, so Ajax calls also use the request component in MooTools.
Grammar:
var myRequest = new Request([options]);
Parameters:
- Options-(object, optional) see the following optional
Available options:
- URL-(string: default is null) the destination URL of the request
- Method-(String: Default is ' post ') HTTP request methods, can be: ' post ' or ' get '
- Data-(string: Default = ") The default request parameters provided for the Request:send method
- Async-(Boolean: Default is True) if False, the request will be synchronized
- Encoding-(string: default = "Utf-8") how the request is encoded
- Link-(String: Default is Ignore) can be ' ignore ', ' Cancel ' or ' chain '
- ' Ignore '-when the request is executing, the new request is ignored
- ' Cancel '-when the request is executing, the current execution request is canceled immediately, and a new request is started
- ' Chain '-when the request is executing, the new request is linked to the current request, followed by all requests
- Headers-(object) Request header data
- Issuccess-(function) can override the built-in issuccess function to customize the rules for request success
Look at an example in Ecstore:
New Request ({url: ' index.php?app=b2c&ctl=admin_specification&act=check_spec_value_id ', onsuccess: function (re) { if (re== ' can ') { row.remove (); } else{ Messagebox.error (re);}} ). Post (' spec_value_id= ' +encodeuricomponent (specvid));
Onsuccess is returned after the Ajax call succeeds, and the parameter is the response content ResponseText
Request also has two extension classes:
Request.html is specifically designed to respond to requests for HTML content, and the important parameters are:
Update-(element: default is NULL) the target element to be inserted by the responsetext of the request response
Evalscripts-(Boolean: Default is True) if true, the contents of the script in the response content will be executed
Evalresponse-(Boolean: Default is False) if true, the entire response content will be executed as a script
Request.json is dedicated to sending and receiving JSON-formatted data, where Ajax calls return a JSON-like
Example:
var jsonrequest = new Request.json ({ URL: "http://site.com/tellMeAge.php", oncomplete:function (person, text) { alert (person.age); Displays "Years". alert (person.height); Displays "+ cm". alert (person.weight); Display "+ kg". }}). Get ({ ' firstName ': ' John ', ' lastName ': ' Doe '});
More Ecstore questions can contact webmaster QQ 1611235299
How to invoke the initiating AJAX request in Ecstore