连接json与extjs [英] connect json with extjs
问题描述
在我的示例登录表单中,我尝试连接到json并获取结果,即true,如果用户名和密码匹配,否则为false。 strong> json (存在于我的项目文件夹中)
{
form:{
login:[
{
username:venkat,
password:123
},
{
username:admin,
password:345
}
]
}
我创建了一个如下的功能。但我不知道下一步该怎么做sencha文档有一些方法,如ajax,代理MVC架构,我没有使用。
function checkJson(username,password) {
//我应该在这里写什么?
//返回true,如果匹配
// else false
}
不要写下未加密的密码。也不会通过teh interwebs发送他们
你可以像这样处理你的JSON(这是问题吗?):
function checkJson(jsonString){
var json = Ext.decode(jsonString);
//json.form.login[0].username;
//json.form.login[0].password;
}
但是@Izhaki说。这是不好的JavaScript,这些检查应该在服务器端完成。
In my sample login form, I am trying to connect to json and get the result ie., true, if username and password matches, else false.
json (exists in my project folder)
{
"form": {
"login": [
{
"username": "venkat",
"password": "123"
},
{
"username": "admin",
"password": "345"
}
]
}
I created a function like below. But I don't know what to do next. The sencha documentation has methods like ajax, proxy for MVC architecture, which I am not using.
function checkJson(username, password){
//What should I write here?
//Return true, if match
//else false
}
Never write down unencrypted passwords. And also never send them via teh interwebs!
You can process your JSON in extjs like this (that is the question right?):
function checkJson(jsonString){
var json = Ext.decode(jsonString);
//json.form.login[0].username;
//json.form.login[0].password;
}
But what @Izhaki said. This is bad javascript and these kind of checks should be done on the server-side.
这篇关于连接json与extjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!