I am trying to access some data from my server inside another domain.
So i have this php code:
header('Content-type: application/json');
$callback = $_GET[callback];
echo $callback . '(' . $CIPHERDATA . ')';
The javascript that runs on the client side is this
$.getJSON("http://mydomain.gr/zerobin-015/?24c3285?callback=?",function(jsondata){
alert(jsondata.data);
alert("hi");
});
The alerts don’t show up.
The only thing that happen’s is the creation of a script tag that has all the information i need but i can’t access.
<script src="http://mydomain.gr/zerobin-015/?24c3285?callback=jsonp1335048265855&_=1335048265874">
({"data":"{\"iv\":\"smDkNQMt0MIbPABPbAb+xQ\",\"salt\":\"aoFfKV+jHhs\",\"ct\":\"Ns17UQZQN\/ktO2hUW+dPug\"}","meta":{"expire_date":1337635538,"postdate":1335043538}})
</script>
Is there something wrong with my json-p format?
What is the proper format of this data so they are accesible?
The problem was on the data format.The json string that should be served by php is:
{“data”:”{“iv”:”smDkNQMt0MIbPABPbAb+xQ”,”salt”:”aoFfKV+jHhs”,”ct”:”Ns17UQZQNktO2hUW+dPug”}”,”meta”:{“expire_date”:1337635538,”postdate”:1335043538}}
The mistake at the php code that i use json_encode two times on the same string.