php收不到ajax,ajax post数据提交 PHP后台接收不到数据

另外$query="select * from gequ where id='$_POST[id]'";

如果你post过来的id是int类型的话 完全没必要加单引号

data:{"id":id},

在JS里面alert一下这个id,看是否有值

title

2.php文件

另外楼上有位说 dataType不用写,下面是引用官方文档的解释。

dataType (default: Intelligent Guess (xml, json, script, or html))

Type: String

The type of data that you're expecting back from the server. I

正常提交请不要加dataType:"json",

否则你需要print_r(json_decode($_POST['id']))这个是数组 不能echo

一下就懂了,缺少json_decode啊,赞个,分就给你了

顺便再问个跟这个没多大关系的问题

$.ajax({

url:"/music/",

type:"POST",

data:{"id":id},

dataType:"json",

success: function(e){

如果URL是这样传递的,这是什么技术呢

我擦 楼主你看看5楼,

你看看 官方给的 介绍:http://api.jquery.com/jquery.ajax/

dataType (default: Intelligent Guess (xml, json, script, or html))

Type: String

The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). The available types (and the result passed as the first argument to your success callback) are:

title

2.php文件

另外楼上有位说 dataType不用写,下面是引用官方文档的解释。

dataType (default: Intelligent Guess (xml, json, script, or html))

Type: String

The type of data that you're expecting back from the server. I

我擦 楼主你看看5楼,

你看看 官方给的 介绍:http://api.jquery.com/jquery.ajax/

dataType (default: Intelligent Guess (xml, json, script, or html))

Type: String

The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). The available types (and the result passed as the first argument to your success callback) are:

你理解错我意思了,dataType是要写的,我问题主要是json_decode而已,你是对的

我说的datatype不用写是如果不牵扯到跨域传值或者js的数组 /对象 的话 字符串完全可解决 所以就没必要加datatype 比如你要已json格式传递

另外 url:"/music/", 很简单就能理解 就是当前目录下的/music/

比如你访问www.xxx.com/music/ 那么如果设置了默认文件了 会直接访问默认文件的

比如默认文件时index.php那么实际就是www.xxx.com/music/index.php

另外json_decode()有2个参数 第一个是json 第二个如果不想要对象的话请写true

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值