Getting Weird responseText



I've a very short php code written just for testing the ajax in a Cordova application.


Code for php is :



<?php

if (isset($_POST["TEST"])){
if ($_POST["TEST"] == "TEST"){
$resp["GOOD"] = "TEST WORKS!!";
echo (json_encode($resp));
}
}
?>


My request code is :



$.post('http://ift.tt/1weeKrM',
{ TEST: 'TEST' },
function (result) {
console.log(result);
$('#txtlbl').text(result);
}
);


I am expecting the responseText to be "TEST WORKS!!" but what I get is :



{"GOOD":"TEST WORKS!!"}&lt;!-- www.serversfree.com Analytics Code --&gt;
&lt;script src="http://ift.tt/GC6Kxn"&gt;&lt;/script&gt;&lt;noscript&gt;&lt;a title="Free hosting servers" href="http://ift.tt/GC6Kxn"&gt;Free servers&lt;/a&gt;&lt;a title="Free websites hosting server" href="http://ift.tt/GC6Kxn"&gt;Free websites hosting server&lt;/a&gt;&lt;a title="Free hosting server features" href="http://ift.tt/1lES9UV"&gt;Free server features&lt;/a&gt;&lt;a title="Free hosting" href="http://www.bugs3.com"&gt;Free hosting&lt;/a&gt;&lt;a title="Page rank" href="http://ift.tt/1iaeucn"&gt;Page rank&lt;/a&gt;&lt;/noscript&gt;
&lt;script type="text/javascript"&gt;

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-24425628-3']);
_gaq.push(['_setDomainName', window.location.host]);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + 'http://.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

&lt;/script&gt;
&lt;script type="text/javascript" src="http://ift.tt/1a5HDg1"&gt;&lt;/script&gt;
&lt;!-- End Of Analytics Code --&gt;


I don't understand whats happening here.


No comments:

Post a Comment