jQuery.Ajax发布到webservice

时间:2012-11-30 09:35:15

标签: javascript jquery

我需要将数据发布到我的后端系统(SAP)。我正在尝试使用以下代码:

硬编码网址示例:

  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);
                }
            });

Web服务通过SOAPUI工作。但不是通过这种方式。

任何人都可以指导这段代码出了什么问题。

亲切的问候, 文森特

1 个答案:

答案 0 :(得分:0)

尝试将标题设置为:

  

标题:{“Content-Type”:“application / x-www-form-urlencoded”}