0

我正在从asp.net 1.1站点调用 Web 方法并得到响应。

我使用这个对象来填充一些数据,现在我想存储这个对象,这样我也可以在保存点击事件的同时将这些数据保存在数据库中。

我怎样才能做到这一点。

 $(document).ready(function () {
            $("#Ok").click(function () {
                $.ajax({
                    type: "POST",
                    url: "/Service.svc/xyz",
                    data: JSON.stringify(jData),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (**msg**) {
                        // STORE THIS msg object.
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                    }
                });
            });
        });
4

2 回答 2

0
$(document).ready(function () {
            $("#Ok").click(function () {
                $.ajax({
                    type: "POST",
                    url: "/Service.svc/xyz",
                    data: JSON.stringify(jData),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(data, textStatus, jqXHR){
                        // STORE THIS msg object.
                        /* now you can store data object to where you want to store.*/
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                    }
                });
            });
        });
于 2012-10-25T10:55:05.490 回答
0
$(document).ready(function () {
        $("#Ok").click(function () {
            $.ajax({
                type: "POST",
                url: "/Service.svc/xyz",
                data: JSON.stringify(jData),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(data){
                    // STORE THIS msg object.
                  //if hidden field has id 'name'
                  $('#name').val(data.name);//if json object contains a key 'name'
                  //if hidden field has class name
                  $('.name').val(data.name);
                  //if hidden field name is name <input type="text" name="name" />
                  $(document).filter(':[name=name]').val(data.name)
                  //do the same for all elements to save
                },
                error: function (jqXHR, textStatus, errorThrown) {
                }
            });
        });
    });
于 2012-10-25T11:15:34.197 回答