以下是我的Ajax代码:
$.ajax({
url: url,
type: type,
data: {data:cart},
success: function(response){
console.log(response);
},
error: function(error){
throw new Error('Did not work');
}
});
我的问题是:当我检查控制台时,响应的是XML文档,而不是cart的POST数据。我试图使用dataType:'text',但这只是在URL中提供代码,而不是POST数据。当我使用dataType:'json'时,我仍然可以得到XML文档。
我的php代码是:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Send.php</title>
</head>
<body>
<?php
print_r($POST);
?>
</body>
</html>
问题可能出在哪里呢?或者我需要添加什么吗?