I am trying to get a URL variable into a jQuery ajax function, in order to quickly adapt some code.
This should be simple, but i'm a bit of an idiot and using the methods described at http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html didn't work out for me.
Essentially I am trying to replace the hard-coded "player_tsid" with a variable on the end of a url, like http://www.example.com/?player_tsid=PIF575TP7IOBA
Here is the code ..
$(function(){
jQuery.support.cors = true;
$.ajax({
'url' : 'http://api.glitch.com/simple/players.getAnimations',
'dataType' : 'json',
'data' : { 'player_tsid' : 'PIF1UFTOS10HF' },
'success' : function(data, textStatus, jqXHR){
if (data.ok){
g_sheets = data.sheets;
g_anims = data.anims;
build_index();
$('#loading').text("Loading sheets...");
load_sheets();
}else{
alert('api error');
}
},
'error' : function(jqXHR, textStatus, errorThrown){
alert('api error');
alert(errorThrown);
}
});
});
,,