Use JQuery.post() with JSON for a secure login form

So I'm tring to create a secure form ( username & password ) with the usernames and passwords stored stored in a Json fil. So I have some questions.

How can I secure that json file will not be accessible by something coming via cross-domain request? Or How can I ensure it will not.

How do I actually use the .post() the function with json. I mean I read the .post() documentation but it doesn't make much sense to me. Not how can I use it with Json at least.

The json variable is something like that: var Arr = secureData.Users;

Any suggestions on how can it be done? It shouldn't be hard from the tutorials that I read but I just don't get it.

PS: I looked into another way but that uses MySQL and PHP but I don't have a MySQL database ( nor want to build one ) and I don't use php at my site.

Answers


What exactly are you trying to achieve?

Do you want to compare the username and password entered by the user to values stored in a file on the server? Then you could use .post() to send the values submitted by the user to the server, let the server perform the comparison and return an indication of whether the authentication succeeded. In this case, although it is certainly possible, there is no particular reason to use the JSON format in the file - CSV, XML or anything like that might be just as (or more) appropriate.

EDIT: If you are not using PHP or any other server-side scripting, how do you expect to do the comparison? You obviously do not want to perform the comparison using javascript, since you will then have to send the correct values to the browser. That would obviously make your authentication mechanism very easy to circumvent / hack.


Just do not return/echo the complete JSON string with usernames/passwords in any way.


Need Your Help

Objective C: ARC with IVars declared in implementation file

automatic-ref-counting instance-variables objective-c-2.0

I found an interesting post describing how, in Objective-C 2.0, instance variables can be declared in the implementation file. Consider this example:

Using KendoUI Charts, How do you make the Legend item a hyperlink?

javascript jquery asp.net telerik kendo-ui

I'm using KendoUI and I have created the following Chart. I need to be able to make the Legend item "Product 1" in this case a hyper link. How Do I do that?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.