DELPHI盒子
!
实时搜索:
标题
作者
盒子论坛
|
注册用户
|
修改信息
|
退出
检举帖
|
全文检索
|
关闭广告
|
捐赠
技术论坛
用户名
密 码
自动登陆(30天有效)
忘了密码
≡技术区≡
①
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
②
发布代码
发布控件
文档资料
经典工具
≡事务区≡
③
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入:
melqui
今日帖子:
12
在线用户:
31
导航:
论坛
->
Web应用开发
斑竹:bodies
作者:
ccxpts
(渔夫)
★☆☆☆☆
-
普通会员
2018/7/2 16:31:13
标题:
使用Extjs.Ajax.Request访问datasnap rest总是报错
浏览:
1403
加入我的收藏
楼主:
使用Extjs.Ajax.Request访问datasnap rest总是报错
ext-all-debug.js :37619 OPTIONS
http://192.168.1.11:8080/datasnap/rest/TServerMethods1/EchoString/HelloWorld 
;500 (Internal Server Error)
Failed to load
http://192.168.1.11:8080/datasnap/rest/TServerMethods1/EchoString/HelloWorld: 
;Response for preflight has invalid HTTP status code 500.
ext-all-debug.js 37619: xhr.send(requestOptions.data);
ExtJS4.1代码如下:
Ext.onReady(function(){
Ext.Ajax.request({
method: 'POST',
url: "
http://192.168.1.11:8080/datasnap/rest/TServerMethods1/EchoString/HelloWorld"
;,
dataType: 'json',
success:function(response){
var data=response.responseText;
alert(data);
},
failure:function(){
alert('failure');
}
});
});
datasnap rest允许跑域访问:
在浏览器访问是这样的:
http://192.168.1.11:8080/datasnap/rest/TServerMethods1/EchoString/HelloWorld
返回:{"result":["HelloWorld"]}
datasnap修改代码如下:
procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
//allows cross domain calls
Response.SetCustomHeader('Access-Control-Allow-Origin','*');
if FServerFunctionInvokerAction <> nil then
FServerFunctionInvokerAction.Enabled := AllowServerFunctionInvoker;
end;
function TServerMethods1.EchoString(Value: string): string;
begin
Result := Value;
end;
----------------------------------------------
-
作者:
delphiilove
(乌羽玉)
★☆☆☆☆
-
普通会员
2018/7/2 16:37:31
1楼:
应该用 Get 方法吧
----------------------------------------------
-
作者:
ccxpts
(渔夫)
★☆☆☆☆
-
普通会员
2018/7/2 16:44:58
2楼:
试了Get,也报同样的错
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2
C
C
C
.Com
盒子论坛
v3.0.1 版权所有 页面执行148.4375毫秒