2017-05-04 42 views
0

在登錄時調用ajax post時獲取最大調用堆棧大小錯誤。不能確切地說明是什麼導致了這個問題。我似乎無法找到任何遞歸函數。在SAPUI5應用程序中獲取最大調用堆棧大小錯誤

這裏是我的xmlView中文件

<mvc:View 
    controllerName="abc.controller.LoginController" 
    xmlns:mvc="sap.ui.core.mvc" 
    xmlns:u="sap.ui.unified" 
    xmlns:c="sap.ui.core" 
    xmlns:m="sap.m" 
    xmlns:l="sap.ui.layout" 
    xmlns:tnt="sap.tnt"> 
    <m:Page 
     id="loginPage" 
     showHeader="false" 
     enableScrolling="false" 
     class="sapUiContentPadding"> 
     <m:Panel width="30%"> 
      <l:Grid> 
       <l:content> 
        <l:VerticalLayout> 
         <m:Label text="User Name" design="Bold"/> 
         <m:Input id="username"/> 
        </l:VerticalLayout> 
        <l:VerticalLayout> 
         <m:Label text="Password" design="Bold"/> 
         <m:Input id="password" type="Password" /> 
        </l:VerticalLayout> 
        <l:VerticalLayout> 
         <m:Button id="loginBtn" text="Login" press="toTablePage" /> 
        </l:VerticalLayout> 
      </l:content> 
      </l:Grid> 
     </m:Panel> 
     </m:Page> 
</mvc:View> 

我的登錄控制器的js文件是

sap.ui.define([ 
    "sap/ui/core/mvc/Controller", 
    "sap/ui/model/json/JSONModel", 
    "sap/m/MessageToast" 
], function(Controller, JSONModel, MessageToast) { 
    "use strict"; 

    return Controller.extend("abc.controller.LoginController", { 

     onInit: function(){ 

     }, 

     toTablePage: function(){ 

      var userName = this.byId("username"); 
      var password = this.byId("password"); 

      if(userName.getValue()!== "" && password.getValue()!== ""){ 



        var aData = jQuery.ajax({ 
         type: "POST", 
         contentType: "application/json", 
         url: "http://localhost:3000/api/logins", 
         dataType: "json", 
         data: jQuery.param({ email: userName, password : password}) , 
         success: function (data, textStatus, jqXHR) { 
          alert(textStatus); 
         } 

        }); 
      } 
      else 
       MessageToast.show("the username or password is wrong"); 
     } 
    }); 
}); 

回答

0

你傳入userNamepassword,有圓形結構的對象,到jQuery.param。您需要通過實際的userName.getValue()password.getValue()

jQuery.param正試圖序列化遞歸對象。哪一個過程永遠不會結束。

+0

謝謝@juan,你能解釋'userName'和'password'是遞歸對象嗎? – user557657

+1

@ user557657這意味着它具有對自身的引用。我不知道遞歸的確切位置*,但想象下面的內容(您可以在devTools中嘗試它): 'var a = {};如果你想把結果對象寫成一個字符串,你會注意到它是一個永無止境的過程:'{self:{self:{self:{self:...} }}' –

相關問題