connect json with extjs

南笙酒味 提交于 2019-12-11 16:34:14

问题


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
}

回答1:


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.



来源:https://stackoverflow.com/questions/14832496/connect-json-with-extjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!