weixin_33675507 2017-01-06 14:29 采纳率: 0%
浏览 25

AJAX发布功能做GET

I'm trying to do a post function after gettings some json files.

But when I press the button that trigger the function the result is a get not a post.

function post(info) {
    $.ajax({
        //type: "POST",
        method: "post",
        data: info,
        url: 'http://www.exefire.com/log',
        dataType: "jsonp",
        async: true,
        success: function(result) {
            console.log(result);
        },
        error: function(request, error) {
            var texto = 'Error conectando con el servidor!';
            alert(texto);
        }
    });
}

I don't know what am I doing wrong.

  • 写回答

1条回答 默认 最新

  • DragonWar% 2017-01-06 14:33
    关注

    Change the dataType property from 'jsonp' to 'json'. It is not possible to make a POST request with jsonp

    function post(info) {
    $.ajax({
        type: "POST",
        data: info,
        url: 'http://www.exefire.com/log',
        dataType: "json",
        async: true,
        success: function(result) {
            console.log(result);
        },
        error: function(request, error) {
            var texto = 'Error conectando con el servidor!';
            alert(texto);
        }
    });
    }
    
    评论

报告相同问题?