Ajax
// GET
function httpTest() { var param = null; var req = { url: 'hello.txt', method: 'GET', data: param, cb: httpTestCb }; util.http(req); } function httpTestCb(xhr, res) { util.infotip.show('Status: ' + xhr.status); // The variable res cotains the response body log(res); } httpTest();
DEMO
// POST
function httpTest() { var param = { name1: 'value1', name2: 'value2' }; var req = { url: '../test/test.cgi', method: 'POST', data: param, cb: httpTestCb }; util.http(req); } function httpTestCb(xhr, res) { util.infotip.show('Status: ' + xhr.status); // The variable res cotains the response body log(res); } httpTest();
DEMO
blank.html
HTTP4096
HTTP4097
HTTP3M
HTTP3M+1
HTTP404
CrossOrigin
timeout:
HTTP_SLEEP
util.http.online
false
true
REGISTER_EVT_LISTENER