无法接听电话?

时间:2012-05-29 20:51:00

标签: 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' + 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') {

    }
}

刚刚使用了一些测试值。

1 个答案:

答案 0 :(得分:3)

摆脱echo ('test');,它不是json。

$.get()不需要表单。

相关问题