jquery - Restrict getJSON / PHP query to server -
this question has answer here:
i using js library requires json data passed in order display information. need parse data via php script, below:
$.getjson('http://example.com/q.php?a=3298&b=test', function(data)...
is there way restrict query server / localhost? don't want third-party person or website being able retrieve data going directly http://example.com/q.php?a=3298&b=test&callback=? .
it sounds want not restrict localhost
, mean server access url (and unless browser running on server , you're person using it, isn't want).
if understand correctly, need visitor accessing site able use within js code, don't want them snag url, modify parameters, , pull arbitrary data server.
if that's case, you'll want encrypt or hash values pass. instead of you're doing now:
http://example.com/q.php?a=3298&b=test
do this:
http://example.com/q.php?token=fjsdfa6f98sfuspojfj
where fjsdfa6f98sfuspojfj
you've pre-created on server corresponds a=3298&b=test
. way, can't screw token
, enter value corresponds other versions of a
, b
.
Comments
Post a Comment