1

こんにちは、フォームなしで 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 とテーブルを使用した GET 呼び出しがありますが、値が返されません (json も php エコーもありません)。

これは私の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') {

    }
}

いくつかのテスト値を使用しました。

4

1 に答える 1

3

を取り除きecho ('test');ます。json ではありません。

$.get()フォームは必要ありません。

于 2012-05-29T20:52:11.400 に答える