我的请求
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;
Get as result
Notice: Undefined index: term in C:'xampp1'htdocs'AppRain'PHPdocs'appsearch.php on line 3
{ "resultCount":0, "results": [] }
我需要发送的术语搜索从我的jscode到php文件通过Post,但我所尝试的一切都没有工作。
我还尝试将type设置为GET,以便它列出GET请求,但Ajax不起作用。但是当我使用get时,我可以使用URL appain .php?term=....没有,我只是把它从浏览器复制到url字段。似乎每个通过$发送的参数。ajax或jQuery。
您正在覆盖您的data
密钥:
data: "text",