[英]jQuery.Ajax Post to webservice
I need to post data to my backend system (SAP). 我需要将数据发布到后端系统(SAP)。 I'm trying to use the following code:
我正在尝试使用以下代码:
Hardcoded the URL example: 硬编码URL示例:
var dataString = ""
//Add TO SAP.
var aData =
jQuery.ajax({
type: "POST",
//contentType: "application/xml",
url: "http://delyo001.you.local:8000/sap/bc/youconsulting/ws/rest/anonymous/z_names_post?firstname=testz&lastname=zefzef", // for different servers cross-domain restrictions need to be handled
data: dataString,
//dataType: "json"
success: function(xml) { // callback called when data is received
//oModel.setData(data); // fill the received data into the JSONModel
alert("success to post");
},
error: function(xml) { // callback called when data is received
//oModel.setData(data); // fill the received data into the JSONModel
alert("fail to post");
alert(xml);
}
});
The webservice works via SOAPUI. 该Web服务通过SOAPUI工作。 But not via this way.
但不是通过这种方式。
Can anyone please guide to what's wrong with this code. 任何人都可以指导此代码出了什么问题。
Kind regards, Vincent 此致Vincent
Try set a header as: 尝试将标头设置为:
header : { "Content-Type" : "application/x-www-form-urlencoded" }
标头:{“ Content-Type”:“ application / x-www-form-urlencoded”}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.