0

おそらくこれは非常に単純かもしれませんが、この ajax 呼び出しが機能しない理由がわかりません。機能するポストコールに相当するものを入れました。

    //this works
    $(document).ready(function () {
        $('#ingresa_usuario_form').submit(function (event) {
            event.preventDefault();
            var url = $(this).attr('action');
            var datos = $(this).serialize();
            $.post(url, datos, function (resultado) {
                $('#posted_values').html(resultado);
            });
        });
    });

    //this doesn't work
    $(document).ready(function(){
        $('#ingresa_usuario_form').submit(function (event) {
            event.preventDefault();
            $.ajax({
                type: "POST",
                url: $(this).attr('action'),
                data: $(this).serialize(),
                dataType: "text/plain",
                success: function (response) {
                    $('#posted_values').html(response);
                }
            });
        })
    });
4

2 に答える 2

0

$ .ajax からのチュートリアルdataTypeのようxmljson、、、、scriptまたはhtml。しかし、「これは機能しない」とは何かについて、より多くの情報が必要です。

于 2013-02-17T16:34:40.393 に答える
0

あなたの URL は contentType "text/plain" を受け入れず、"application/x-www-form-urlencoded; charset=UTF-8" である $.post のデフォルトの contentType のみを受け入れているようです。これが役に立ったことを願っています。

于 2013-02-17T16:13:23.983 に答える