Javascript Post参数不会从ajax请求发送到PHP
我的要求Javascript Post参数不会从ajax请求发送到PHP,javascript,php,jquery,ajax,http-post,Javascript,Php,Jquery,Ajax,Http Post,我的要求 jQuery.ajax({ url: 'PHPdocs/appsearch.php', data: {term:'blub'}, type: "POST", async: true, data: "text", success: function(msg){
jQuery.ajax({
url: 'PHPdocs/appsearch.php',
data: {term:'blub'},
type: "POST",
async: true,
data: "text",
success: function(msg){
$('div[data-role="content"]').append(msg);
},
error: function(msg){}})
我的PHP文件
$json = file_get_contents("https://itunes.apple.com/search?country=de&entity=software&
term=".$_POST['term'];);
$results = json_decode($json, true);
echo $json;
结果是什么
Notice: Undefined index: term in C:\xampp1\htdocs\AppRain\PHPdocs\appsearch.php on line 3
{ "resultCount":0, "results": [] }
我需要通过Post将搜索术语从我的jscode发送到php文件,但我尝试的一切都不起作用
我还尝试将type设置为GET,以便它是一个GET请求,但Ajax不起作用。但是,当我使用get时,我可以将它与URL appain.php?term=。。。。如果没有,我只将其从浏览器复制到url字段。似乎通过$.ajax或jQuery.ajax发送的每个参数都被阻止,请有人帮助我。您正在覆盖您的
数据
键:
data: "text",
您应该删除该行。我想您是想在该行中使用“数据类型”,以便您的脚本需要返回文本。你也可以跳过那一行。文本是默认值。确定发现问题,我键入了数据而不是数据类型