Mr_Green
Mr_Green

Reputation: 41872

connect json with extjs

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
}

Upvotes: 0

Views: 191

Answers (1)

A1rPun
A1rPun

Reputation: 16857

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.

Upvotes: 1

Related Questions