Javascript Jquery getJson send$\u GET var检索正确的json字符串
我在getjson url的顶部有这个Javascript Jquery getJson send$\u GET var检索正确的json字符串,javascript,jquery,json,Javascript,Jquery,Json,我在getjson url的顶部有这个 if(isset($_GET['template']) && $_GET['template']=="blue") { $inifile_path="ctr/subthemes/blue/"; } else { $inifile_path="ctr/subthemes/fresh-n-clean/"; } 当我点击一个链接时,我在主页上看到了: $('a[id^=color]').bind('click',function(){
if(isset($_GET['template']) && $_GET['template']=="blue") {
$inifile_path="ctr/subthemes/blue/";
} else {
$inifile_path="ctr/subthemes/fresh-n-clean/";
}
当我点击一个链接时,我在主页上看到了:
$('a[id^=color]').bind('click',function(){
var template = $(this).attr('rel');
var jsonurl ="http://www.mysite.org/wp-content/themes/ctr-theme/update_genform.php?theme="+template;
//load current ini color values into the form values
$.getJSON(jsonurl,function(data) {
链接是:
<a href="#" id="color3" rel="blue">Color</a>
我看不出我可能做错了什么,我也不知道如何在json generator.php上测试$\u GET输出,因为它通过json调用:\
什么可能是错误的?由于我怀疑模板变量没有被正确提交,因此上述操作无法正常工作,因为我总是得到“else if”结果,而且从来没有有效的匹配项您是否尝试将模板参数作为参数而不是显式查询字符串传递
$.getJSON('siteUrl',
{"theme" : template},
function(data){
// callback data from server
}
);
试试这个:
if(isset($_GET['theme']) && $_GET['theme']=="blue"){
}
主要错误在PHP脚本中。因为您使用了
$\u GET['template']
,但您将URL参数作为主题发送。所以我认为以上是正确的解决方案,尽管我是jquery的新手。OMG!!!!:我已经起床20个小时了。。。非常感谢你指出这一点。。。我这方面真是个白痴:(@Joricam谢谢,朋友。错误是程序员生活的一部分。所以继续吧。programmin确实很有趣,让不完美的容易出错的人来负责构建完美的系统,哈哈,这真是一个悖论!我从来都不新,我可以!非常感谢你,还要尝试一下。请编辑你的awnser并删除url,我忘了删除它,只是更改它而已去mysite什么的谢谢