Ajax 在SAPUI5应用程序中获取最大调用堆栈大小错误
登录时调用ajax post时获取最大调用堆栈大小错误。无法准确找出导致此问题的原因。我似乎找不到任何递归函数 这是我的xmlview文件Ajax 在SAPUI5应用程序中获取最大调用堆栈大小错误,ajax,sapui5,Ajax,Sapui5,登录时调用ajax post时获取最大调用堆栈大小错误。无法准确找出导致此问题的原因。我似乎找不到任何递归函数 这是我的xmlview文件 您正在将具有循环结构的对象userName和password传递到jQuery.param。您需要传递实际的userName.getValue()和password.getValue() jQuery.param正在尝试序列化递归对象。这是一个永远不会结束的过程。谢谢@juan,你能解释一下userName和password是如何递归对象的吗?@user55
您正在将具有循环结构的对象
userName
和password
传递到jQuery.param
。您需要传递实际的userName.getValue()
和password.getValue()
jQuery.param
正在尝试序列化递归对象。这是一个永远不会结束的过程。谢谢@juan,你能解释一下userName
和password
是如何递归对象的吗?@user557657这意味着它有对自身的引用。我不知道递归的确切位置,但是想象一下(您可以在devTools中实际试用):var a={};a、 self=a
如果您想将结果对象作为字符串写入,您会注意到它是一个永不结束的过程:{self:{self:{self:{self:…}}
<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>
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");
}
});
});