arielbf
asked on
Run ajax every 5 secs
Hi,
I need to run a query every 5 secs from to start when window loads.
This should simulate a person to person negotiation.
Here is my script:
<script>
$(document).ready(function (){
refreshTable();
});
function refreshTable(){
$('#tableHolder').load('ne gotiation1 .asp',
{seller:'<%=session("partn er")%>'},
function(){
setTimeout(refreshTable, 5000);
});
}
</script>
the html later:
<div id="tableHolder">....</div >
negotiation1.asp is expecting "seller" parameter as POST query.
However the parameter is not working - I get the table without contents.
Any ideas?
I need to run a query every 5 secs from to start when window loads.
This should simulate a person to person negotiation.
Here is my script:
<script>
$(document).ready(function
refreshTable();
});
function refreshTable(){
$('#tableHolder').load('ne
{seller:'<%=session("partn
function(){
setTimeout(refreshTable, 5000);
});
}
</script>
the html later:
<div id="tableHolder">....</div
negotiation1.asp is expecting "seller" parameter as POST query.
However the parameter is not working - I get the table without contents.
Any ideas?
ASKER
It is working now in Chrome and Firefox
not in IE...
not in IE...
<script>
$(function(){
setInterval(refreshTable, 1000);
});
function refreshTable(){
$.ajax({
url: 'negotiation1.asp',
data: {seller: '<%=session("partner")%>',
type: 'POST',
success: function(response) {
$('#tableHolder').html(response);
}
});
</script>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The same problem - the script is working on Chrome and Firefox, not working on IE
ASKER
To be more specific - it seems that the "setInterval" is not working
Are there any errors?
setInterval is a javascript function going forever.
I tested my code on IE8 and it works perfectly - so somewhere in your code you have another problem that is causing it to fail on IE
What version of IE is this not working on
What version of JQuery are you using - if 2.x check the jquery.com site for compatibility with older versions of IE.
setInterval is a javascript function going forever.
I tested my code on IE8 and it works perfectly - so somewhere in your code you have another problem that is causing it to fail on IE
What version of IE is this not working on
What version of JQuery are you using - if 2.x check the jquery.com site for compatibility with older versions of IE.
ASKER
Well I stripped it from anything else - and it still not working on IE (no problem in Chrome and Firefox)... Here is the current code:
mainpage.asp:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(function(){
setInterval(refreshTable, 1000);
});
function refreshTable(){
$.ajax({
url: 'negotiation4.asp',
success: function(response) {
$('#tableHolder').html(res ponse);
}
});
}
</script>
</head>
<body>
<div id="tableHolder">Table will appear here....</div>
</body>
</html>
and here is the current negotiation4.asp:
<table border='1'>
<tr>
<th>Time</th>
<th>From</th>
<th>to</th>
<th>Comment</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</table>
I'm trying to add rows manually to the table in negotiation4.asp and upload it to the server.
Firefox and Chrome shows me the changes that I made without having to refresh the main page.
IE is not showing the changes - even when I'm refreshing the mainpage page manually.
mainpage.asp:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(function(){
setInterval(refreshTable, 1000);
});
function refreshTable(){
$.ajax({
url: 'negotiation4.asp',
success: function(response) {
$('#tableHolder').html(res
}
});
}
</script>
</head>
<body>
<div id="tableHolder">Table will appear here....</div>
</body>
</html>
and here is the current negotiation4.asp:
<table border='1'>
<tr>
<th>Time</th>
<th>From</th>
<th>to</th>
<th>Comment</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</table>
I'm trying to add rows manually to the table in negotiation4.asp and upload it to the server.
Firefox and Chrome shows me the changes that I made without having to refresh the main page.
IE is not showing the changes - even when I'm refreshing the mainpage page manually.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It is working now :-)
read it directly from the server, don't send it as parameter