Javascript 如何从xhrpost函数中检索响应数据并将该对象存储在dojo/store中?

Javascript 如何从xhrpost函数中检索响应数据并将该对象存储在dojo/store中?,javascript,dojo,Javascript,Dojo,我已经用和创建了一个登录名。我正在使用提交我的登录表单数据。提交是通过onClick函数执行的。从rest方法返回响应。如何将响应对象存储在dojo/store中,例如?这样我就可以在任何html页面中检索它,并删除要注销的对象 dojo.xhrPost({ url: "http://localhost:8080/userservices/rest/rest/login", form: dojo.byId("formNode"), load: function(user,

我已经用和创建了一个登录名。我正在使用提交我的登录表单数据。提交是通过onClick函数执行的。从rest方法返回响应。如何将响应对象存储在dojo/store中,例如?这样我就可以在任何html页面中检索它,并删除要注销的对象

dojo.xhrPost({
    url: "http://localhost:8080/userservices/rest/rest/login",
    form: dojo.byId("formNode"),
    load: function(user,status) {

        if(status.xhr.status == 200) {
            alert(user); //---> which displays username from the response method in rest method
            // What code for could be here for storing that user as an object to dojo store or memory to access several pages and delete the object?
            window.location.href ="jobseekerdashboard.html";                                                
        }
    }
});

不推荐使用dojo.xhrPost。看一看

但是,如果更改窗口位置,将丢失当前环境。如果要更改页面位置,则必须在页面加载后发出新的ajax请求,或者必须在会话数据中传递数据

require(["dojo/request/xhr", "dojo/store/Memory"], function(xhr, Memory){
  xhr("http://localhost:8080/userservices/rest/rest/login", {
    method: "POST",
    data: dojo.byId("formNode")
  }).then(function(returnedData){
    new Memory({
      data: returnedData
    });
    window.location.href= "jobseekerdashboard.html";
  }, function(err){
    // Handle the error condition
  }
});