Jquery 没有表格就可以接到电话吗?
嗨,我需要知道是否有可能在没有表单的情况下进行ajax GET调用 我试过:Jquery 没有表格就可以接到电话吗?,jquery,ajax,json,Jquery,Ajax,Json,嗨,我需要知道是否有可能在没有表单的情况下进行ajax GET调用 我试过: $(".edit_event").live("click", function() { var currentID = $(this).data("event-id"); var currentTable = $(this).data("table"); if (currentTable == 'Coffee_talk') { alert('Erzaehlcafe mit ID
$(".edit_event").live("click", function() {
var currentID = $(this).data("event-id");
var currentTable = $(this).data("table");
if (currentTable == 'Coffee_talk') {
alert('Erzaehlcafe mit ID' + currentID);
$.ajax({
url: 'index.php?section=event_select&id=' + currentID + '&table=' + currentTable,
type: 'GET',
dataType: 'json',
success: function (select) {
alert(select);
}
});
return false;
} else if (currentTable == 'Presentation') {
alert('Vortrag mit ID' + currentID);
} else if (currentTable == 'Exhibition') {
alert('Ausstellung mit ID' + currentID);
}
});
使用Firebug进行调试时说,有一个ID和Table的GET调用,但我没有得到任何值(没有json或php echo)
这是我的php:
if ('GET' == $_SERVER['REQUEST_METHOD']) {
if ($_GET['table'] == 'Coffee_talk') {
echo ('test');
$response['code'] = '1';
echo json_encode($response);
}
if ($_GET['table'] == 'Presentation') {
}
if ($_GET['table'] == 'Exhibition') {
}
}
只是使用了一些测试值。去掉echo('test')代码>,它不是json
$.get()
不需要表单。thx deleted echo语句。使用以下代码:$.get(“index.php?section=event_select&id=“+currentID+”&table=“+currentTable,函数(数据){alert(数据);},“json”);返回false代码>但是我没有得到JSON。你得到了[object object]
?好的,sry找到了错误。我想使用event_edit section,但在编写代码时,我倾向于使用event_select,并且没有定义新的section。。现在可以工作了(thx;)