JQuery post JSON object to a server

后端 未结 2 1596
礼貌的吻别
礼貌的吻别 2020-11-27 04:36

I create a json that needs to be posted in jersey, a server running by grizzly that has a REST webservice gets incoming json object which need to be outputed. I\'m giving a

2条回答
  •  甜味超标
    2020-11-27 05:23

    It is also possible to use FormData(). But you need to set contentType as false:

    var data = new FormData();
    data.append('name', 'Bob'); 
    
    function sendData() {
        $.ajax({
            url: '/helloworld',
            type: 'POST',
            contentType: false,
            data: data,
            dataType: 'json'
        });
    }
    

提交回复
热议问题