This commit is contained in:
zuiidea
2016-12-12 23:36:59 +08:00
parent f0ca3f172c
commit ef61551341
8 changed files with 128 additions and 25 deletions
+17 -11
View File
@@ -8,16 +8,22 @@ const Ajax = require("robe-ajax")
* @return {object} An object containing either "data" or "err"
*/
export default function request(url, options) {
return Ajax.ajax({
if (options.cross) {
return Ajax.getJSON("http://query.yahooapis.com/v1/public/yql", {
q: "select * from json where url=\'"+url+"?"+Ajax.param(options.data)+"\'",
format: "json"
})
} else {
return Ajax.ajax({
url: url,
method:options.method||'get',
data:options.data||{},
processData:options.method=='get'?true:false,
dataType:'JSON',
})
.done((data) => {
return data
})
method: options.method || 'get',
data: options.data || {},
processData: options.method == 'get'
? true
: false,
dataType: 'JSON'
}).done((data) => {
return data
})
}
}