[英]POST 500 (Internal Server Error) ajax xml
I have tried the ajax POST method. 我已经尝试过ajax POST方法。 and below is my code
下面是我的代码
$(document).ready(
function(){
$('#cloneform').click(function(){
$.ajax({
type : "POST",
url : "my server url",
data : { inputxml: escape("<?xml version='1.0' encoding='UTF-8'?><document-id>my data</document-id>") },
dataType : "text/xml",
contentType: "application/xml",
success : function(data){
alert(data);
},
error : function() {
alert('Failed');
}
});
});
}
);
and I tried the same using the postman i got the response as 我用邮递员尝试了同样的方法
<?xml version="1.0" encoding="UTF-8"?>
<document-id>data for server</document-id>
but with javascript i am getting Internal server Error
. 但是用JavaScript我得到
Internal server Error
。
Can anyone figure our error? 谁能弄清楚我们的错误?
Thanks pkalyan 谢谢pkalyan
"Internal server error" doesn't tell us much. “内部服务器错误”并没有告诉我们太多。 Just that something your server side code tried to do threw an error.
只是服务器端代码尝试执行的操作引发了错误。 You should debug it on the server.
您应该在服务器上调试它。
That said: 说:
data : { inputxml: escape("<?xml version='1.0' encoding='UTF-8'?><document-id>my data</document-id>") },
escape
is the old, broken way to encode data for URLs. escape
是一种古老的,破旧的为URL数据编码的方法。 You aren't encoding data for URLs. 您不是在为URL编码数据。 Don't use it here.
不要在这里使用它。
dataType : "text/xml",
dataType
describes the data you expect back from the server. dataType
描述您希望从服务器dataType
的数据。 text/xml
is not a valid value for it. text/xml
无效。 text
is and xml
is. text
是和xml
是。
contentType: "application/xml",
This is probably the cause of your problem. 这可能是造成您问题的原因。
You are claiming to send an XML formatted request. 您声称要发送XML格式的请求。 This is a lie.
这是个谎言。 You are passing
data
an object, so jQuery will URL Form Encode it. 您正在将
data
传递给对象,因此jQuery将对其进行URL表单编码。
Remove this line or change your data
so it is a string of XML. 删除此行或更改您的
data
,使其为XML字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.