0

淘汰赛新手,Js 新手,我是一名 dot net 开发人员,正在尝试使用淘汰赛创建登录屏幕,发布数据正常,接收响应好,只是不知道如何更新单个 observable,请帮助...

function AppViewModel() {
this.email = ko.observable("Bergmail.com");
this.password = ko.observable("Password");
this.logonresult = ko.observable("logon resul");
//computed
this.Computedresult = ko.computed(function () {
    return this.email() + " " + this.password();
}, this);
    //behavious
this.Loginajax = function () {

    var self=this
    $.ajax("Indi-Dal-Json.asmx/CheckLogon" ,{
        data: ko.toJSON({ email: this.email,password: this.password}),
        type: "post", contentType: "application/json",
        success: function (ajaxjsondata) {
            {
                // var parsedjson = JSON.parse(result.b);
                //AppViewModel.logonresult = (result.d);
                self.logonresult = ajaxjsondata.d;
            }

        }
    });
   };
 }
4

2 回答 2

1

self.logonresult是一个可观察的,所以你需要调用它而不是用一个新值覆盖它的引用。

改变

self.logonresult = ajaxjsondata.d;

self.logonresult(ajaxjsondata.d);

http://knockoutjs.com/documentation/observables.html#reading_and_writing_observables

于 2013-10-19T11:06:52.990 回答
0

安德斯回答

self.logonresult(ajaxjsondata.d);

http://knockoutjs.com/documentation/observables.html#reading_and_writing_observables

于 2014-02-25T18:54:09.533 回答