I’ve this code
<script type="text/javascript">
var nextUrlArticle = null;
$(document).ready(function() {
$.get("{{ path('next_video_url', { 'id' : article.id })}}", function(result) {
nextUrlArticle = result.url;
});
function getNextVideo(ext) {
if (nextUrlArticle) {
window.location.href = nextUrlArticle;
}
}
});
</script>
And it never passes into the “window.location.href” which is totally normal because it’s initialized with null and there are an ajax call which updates the parameter but as it’s asynchrone it doesn’t has an effect when the code is processed.
But I really need to check if the nextUrlArticle is not empty, so i can’t remove that check.
The getNextVideo will be called by a flash video player at the end of the video. (I don’t have the hand on this part of the code)
How to make that check pass ?
Thanks.
Ok, i needed to place the
getNextVideo()OUTSIDE the$(document).ready(function() {because the video player couldn’t call the function inside the .readyGood to know.