Using jquery to make a POST, how to properly supply 'data' parameter?

后端 未结 5 700
生来不讨喜
生来不讨喜 2020-11-30 11:01

I\'d like to make an ajax call as a POST, it\'s going to go to my servlet. I want to send parameterized data, like the following:

var mydata = \'param0=some_         


        
5条回答
  •  暖寄归人
    2020-11-30 11:43

    can this help you

    function CallPageSync(url, data) {
        var response;
        $.ajax({
            async: false,
            url: url,
            data: data,
            timeout: 4000,
            success: function(result) {
                response = result;
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                response = "err--" + XMLHttpRequest.status + " -- " + XMLHttpRequest.statusText;
            }
        });
        return response;
    }
    

    and you can call it like

    response = CallPageSync(checkPageURL, "un=" + username);
    

提交回复
热议问题