nicedone
asked on
i am trying to implement simple ajax polling mechanism
Hi,
I do have an xml file in my application and i would like to implement a simple ajax polling mechanism but i am failing to do this .My showdata function below is fine and it accesses to xml and displays the data i need to display
but i want this function to be called every 30 seconds and if an update occured on the file i would like to display it on my page.
i am trying to follow a blog here: http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery but although i try their code to poll in every 30 sec ,i cant seem to get this right. could you help me?
I do have an xml file in my application and i would like to implement a simple ajax polling mechanism but i am failing to do this .My showdata function below is fine and it accesses to xml and displays the data i need to display
but i want this function to be called every 30 seconds and if an update occured on the file i would like to display it on my page.
i am trying to follow a blog here: http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery but although i try their code to poll in every 30 sec ,i cant seem to get this right. could you help me?
(function () {
$.ajax({
url: "http://localhost:21301/", success: function (data) {
//Update your dashboard gauge
console.log('inside the function');
showData();
}, dataType: "json"
});
}, 30000);
var showData=(function () {
$.ajax({
type: "GET",
url: "Data.xml",
dataType: "xml",
success: function (xml) {
var test = $(xml).find('k').text();
$('#result span').html(test);
}
});
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.