Fork me on GitHub Fork me on GitHub

get()


<%
var url  = "https://api.twitter.com/1/statuses/user_timeline.json";
var data = { include_entities:true,include_rts:true,screen_name:"wso2",count:1 };
var twitterJson = get(url, data ,"json");
print(twitterJson);
%>

Overview

get() is a wrapper for XMLHTTPRequest's GET method. using get() you can avoid the use of XHR and shorten the server-side get requests

get(url[, data][, headers][, type][, success(data, xhr)])
var res = get(url[, data][, headers][, type])


Parameters

Parameter Type Description
urlString
var url = "http://www.webservicex.com/globalweather.asmx/GetWeather"
The URL which HTTP get is performed
dataObject
var param = {CityName: "Dalian", CountryName:"China"}
Request parameters
typeString
var type = "xml";
The type, which the response is expected
headersObject
var headers = {"From": "user@example.com"};
Optional HTTP headers
success(data:Object,
xhr:Object)
functionOn success callback

Return values

Value Type Description
dataObjectContains the return data of the HTTP GET request
xhrObjectContains an instance of XMLHTTPRequest