2

JSON文字列を送信しようとしています

var json = {"city":value1, "country":value2};
$.ajax({
    url : url,
    data : json,
    dataType : 'json',
    success : function(response) {
        alert(response);
    }
})

URL私が ajax 呼び出しを行う場所で、この文字列値を取得する方法がわかりませんか? 何を使えばいいrequest.getParameterですか?パラメータの値は何ですか?

4

3 に答える 3

3

Ajax リクエスト:

 var jsonObj= { jsonObj: [... your elements ...]};

    $.ajax({
        type: 'post',
        url: 'Your-URI',
        data: JSON.stringify(jsonObj),
        contentType: "application/json; charset=utf-8",
        traditional: true,
        success: function (data) {
            ...
        }
    });

サーバー側:

String city =    request.getParameter("city");

String country=    request.getParameter("country");
于 2013-04-05T15:42:16.430 に答える