Calling :
$.ajax({
type: "POST",
url: 'http://blahblah/cow.php',
contentType: "application/json",
data: {
'guid': '111',
'score': 592,
'initials': 'tod'
},
success: function (data) {
try {
//alert(data + " -- " + data.length);
if (data.length > 0) {
Doing this in my php page:
echo ('[{error : "' . $error . '", rank : "' . $usersRank . '", totalScores : "' . $totalScores . '"}]');
But JQ just keeps seeing this as text and won’t recognize it as JSON… what am I doing wrong?
Ive tried getting rid of square brackets (nothing), using json_encode – but that was adding quotes to my variables and it still didnt work, tried adding headers(COntent type) to the php page… Argh! Cant figure this out!
DO I HAVE TO CALL DIE or something like that (kind of like Response.end)?
I don’t know what I am doing wrong but I finally just did this… I stopped using Content-type in php or dataType in ajax call and just took the data ‘string’ and called
on it and then perform what I wanted to on it.