Static Methods
Fetch remote resource by HTTP "GET" method
maptalks.Ajax.get(
'url/to/resource',
(err, data) => {
if (err) {
throw new Error(err);
}
// do things with data
}
);
Parameter |
Type |
Description |
url
|
String
|
resource url |
cb
|
function
|
callback function when completed |
Returns:
Ajax:
Ajax
(static) post(options, postData, cb)
[source]
Fetch remote resource by HTTP "POST" method
maptalks.Ajax.post(
{
'url' : 'url/to/post'
},
{
'param0' : 'val0',
'param1' : 1
},
(err, data) => {
if (err) {
throw new Error(err);
}
// do things with data
}
);
Parameter |
Type |
Description |
options
|
Object
|
post options
Properties
Parameter |
Type |
Description |
url
|
String
|
url |
headers
|
Object
|
HTTP headers |
|
postData
|
String
|
Object
|
data post to server |
cb
|
function
|
callback function when completed |
Returns:
Ajax:
Ajax
Fetch resource as a JSON Object.
maptalks.Ajax.getJSON(
'url/to/resource.json',
(err, json) => {
if (err) {
throw new Error(err);
}
// json is a JSON Object
console.log(json.foo);
}
);
Parameter |
Type |
Description |
url
|
String
|
json's url |
callback
|
function
|
callback function when completed. |