定义为模型及其关联,我希望http调用遵循restful的最佳实践。例如,如果我打电话
user.posts();我希望运行一个定义为
users/1/posts如果使用id 32发出呼叫,则引用的url必须为
users/1/posts/32因此,我希望避免使用filter属性,这是get的默认设置。
/posts.php?filter=[{"property":"user_id","value":1}] 这是因为api rest已经定义了,我无法更改它们。我想构建一个微创的解决方案,并在各种论坛上阅读,最好的方法是,方法buildURL,buildURL,proxy rest,,但是无法检索构建最终URL所需的所有数据。有人能给我举个例子吗?
谢谢
发布于 2014-11-24 11:38:09
尝试以下几点:
window.serverUrl = "192.168.1.XX"
var service = "login.php"
var dataTosend: {
username:"xx",
password: "yy"
}
var methode:"POST" / "GET"
this.service(service,methode,dataTosend,onSucessFunction,onFailureFunction);
onSucessFunction: function(res) {
alert("onSucessFunction"):
},
onFailureFunction: function(res) {
alert("onFailureFunction"):
},
service: function(svc, callingMethod, data, successFunc, failureFunc) {
Ext.Ajax.request({
scope: this,
useDefaultXhrHeader: false,
method: callingMethod,
url: window.serverUrl + svc,
params: data,
reader: {
type: 'json'
},
failure: failureFunc,
success: successFunc
});我希望这能解决你的问题。
https://stackoverflow.com/questions/26962592
复制相似问题