javascript - ajax function not triggering on page load -
i'm trying use this: https://github.com/derekmartinez18/simple-ajax-spotify-now-playing , have simple function shows i've listened on spotify:
function get_spotify() { $.ajax({ type: 'post', url: 'spotify.php', data: { request: 'true' }, success: function(reply) { $('.now-playing').html("<p>" + reply + "</p>"); } }); }; the problem it's not triggering. if i'm in console , type
get_spotify() it work , result shows on page.
this piece of js called in .js file before closing of body tag this:
<script type="text/javascript"> function downloadjsatonload() { var element = document.createelement("script"); element.src = "js/build/production.min.js"; document.body.appendchild(element); } if (window.addeventlistener) window.addeventlistener("load", downloadjsatonload, false); else if (window.attachevent) window.attachevent("onload", downloadjsatonload); else window.onload = downloadjsatonload; </script> i tried adding right after function in js file nothing happens, tried closure function or wrapped in document ready function, won't trigger. can't problem :/ help?
i've tested code in fiddle, , works self. when add code unminified js file, halts execution.
so, while can't point every possible error in huge production.min.js file, know there errors , stopping code progressing.
this few lines, easy find, syntax error (might encoding issue, there errors reported regardless):
// jquery twitter feed. coded by... $(document).ready(function () { Â Â Â Â Â var displaylimit = 3; Â Â Â Â var twitterprofile = "vlrprbttst"; Â Â Â Â var screenname = "v ... i'm sure there others. file doesn't stable
edit:
apparently error due to..
$(window).resize(function() { navheight(); })(); should be:
$(window).resize(function() { navheight(); }); full credits @grundy finding , correcting error.
Comments
Post a Comment