|
$.ajax returns JSON but not storing in variable
I'm looking to pull the responseText from this AJAX request, nothing complicated, right? Well as soon as I set my dataType to "json" or "jsonp" then my script fails to grab any responseText, when I know for a fact (using Firebug) that I have JSON as a response. It fails to even get to the success function. If I take out the dataType, then the success function fires but I get nothing as responseText. It's been two days and I can't seem to figure out what the heck is going on. My code below does everything I want it to, except store it to the variable (and call the success.) If I call the variable after doing this AJAX call, it simply tells me that the variable is undefined.
<script language="javascript" type="text/javascript">
var tempJSON = $.ajax({
type: "GET",
dataType: "jsonp",
processData: false,
url: "http://www.kylematheny.com/siteground.php?jsoncallback=?",
success: function() {
alert('Success!');
}
});
</script>
*I've tried to add $.ajax({...}).responseText and still nothing. Using Firebug, the response is {"GEM":"25"}, which is exactly what I want, but I can't figure out how to store the json and recall it later in my script.
Please help!
|