PDA

View Full Version : json parsing problem...urgent


jijodasgupta
06-08-2009, 01:11 PM
<!-- this is the javascript json parser function -->

<script type="text/javascript" src="../jquery-1.2.6.min.js">
</script>

<script type="text/javascript">

$(document).ready(function()
{
$('form#search').bind("submit", function(e)
{
e.preventDefault();
$('#content').html('');

var query1 = urlencode($('input[name="user_a"]').val()); //userA
var query2 = urlencode($('input[name="user_b"]').val()); //userB


$.getJSON('http://twitter.com/friendships/exists.json?user_a='+query1+'&user_b='+query2,
function(data)
{

console.log(data);
if(data.text == 'true')
{
var newDiv = '<p>true</p>';
}

$('#content').append(newDiv);

});
});
});

function urlencode(str) {
return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}
});

</script>

<!-- javascript ends here -->


this is the json code...its fairly simple...the response of getJSON wil give back either true or false....now i dunno why the code is not responding... any help will be appreciated...
thnx..

A1ien51
06-09-2009, 02:53 PM
Have you used a tool such as Fiddler or Firebug to see what is happening with the call?

Are you sure you have a string and not a Boolean?

Eric