Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$.getJSON and PHP file

Tags:

jquery

php

Is it possible to hide name of *.php file in

$(document).ready(function(){
$.getJSON("getdata.php", function(returned_data) { 
    if(returned_data === "1") {
        $("div#wall").html('user has no subscription');
        $("#message_wall").attr("disabled", "disabled");
        return false;
    }
});

});

Because that jquery code will be visible in source code of the page and I do not want to some malicious visitors try to do something with it.

like image 606
Sergio Avatar asked Dec 17 '22 02:12

Sergio


1 Answers

The short answer is no, you must secure this server-side. Anything a client can run, they can see...and anyone trying to be malicious can certainly figure out.

Even if you hid it under 15 layers of obfuscation, ultimately the browser still makes a request to a url, and any debugging tool can see that, FireBug, Fiddler, etc.

A session based approach, or cookies, something, anything to check that the user is authenticated/authorized on the server-end is the best approach.

like image 90
Nick Craver Avatar answered Dec 30 '22 02:12

Nick Craver