【发布时间】:2012-08-07 19:32:10
【问题描述】:
你好,我有下面的代码:
<script type="text/javascript">
14 $(document).ready(function() {
15 $('#find').click(function(){
16
17 var amount = $('#amount').val();
18
19 $.ajax({
20 type: "POST",
21 contentType: "text/xml;charset=utf-8",
22 url: "questions.php",
23 data: {'amount': amount},
24 success: function(data){
25
26 $('#results').show();
27
28
29 $('#results').html(data);
30 }
31 });
32 });
33 });
34 </script>
我的 php 脚本代码如下
5 $search_term = $_POST['amount'];
6 echo $search_term;
如果我删除第 21 行内容类型的东西,我将输入作为输出,但我没有任何输出!问题是我真的需要内容类型的东西,所以任何关于它的信息都会非常有帮助!
【问题讨论】:
-
PHP 是否获取数据?
-
如果我有内容类型的东西,我猜不(我没有输出)!如果我删除它,是的,因为我得到了回声!
-
从你的 js 中删除第 21 行。 var_dump($_POST);在接收请求的 php 文件中。它能给你你想要的吗?您还可以将 dataType: 'JSON' 添加到您的 ajax 参数中。
-
The thing is that i really need the content type thing你不是发送xml,为什么需要内容类型来指定xml? -
如果我删除该行,我会得到 array(0) { } 但我需要该行,我需要在帖子中设置内容类型!