I am new to the jQuery and currently trying to implement an ajax call which will permanently poll the server and request some data. The ajax is working fine as i was able to hit my server side controller method however after adding a data: gameLink param it is stopped working. Here is my jQuery function:
window.setInterval(pollActiveParticipants, 10000);
function pollActiveParticipants() {
$.ajax({
type: "GET",
url: "pollActiveParticipants",
data: {"gameLink": $gameLink }, //this is where i need help!
dataType: 'json',
success: function(data){
$.each(data, function(index, value) {
'<p>' + value.username + '</p><br>';
});
}
});
}
The $gameLink is present on the jsp as few lines below i am using it as
<br>
Other participants can access the game on the following url: ${gameLink}
<br>
What is the correct syntax to add the $gameLink as request param or what I am doing wrongly?
Have you tried like this?
or
Hope this helps.
I'll take a stab and guess
$gameLink
is a GSP var and not a JS var... In which case you need to string quote it thus: