This should be really simple, so, either I am over thinking it or making it more complicated than it should be.
I would like to update a DIV without having to reload the webpage.
A form on Canvas.asp queries the database and returns the coordinates of a GPS device. The coordinates are updated every minute and would like the script to return the latest coordinates without having to refresh the page. The coordinates are appended to a separate XML file.
I have written this;
<script type="text/javascript">
$(document).ready(function() {
$("#map").load('canvas.asp');
var auto_refresh = setInterval(function() {
$("#map").load('canvas.asp?std=<%=session("7digit")%>&submit=Search&execute=1');
}, 60000);
$.ajaxSetup({ cache: false });
});
</script>
The div to be reloaded;
<div id="map"></div>
The script returns an error by duplicating the header and content, after 60 seconds the map DIV is nowhere to be seen... Simply disappears! The coordinates are appended to the XML file every 60 seconds, even after the error.
What am I doing wrong?
canvas.asp?std=<%=session("7digit")%>&submit=Search&execute=1only returns contents of thedivyou require, at the moment I would bet the request returns a full HTML document which will not load into adiv. Use something like Chrome Dev Tools (F12) and check the network tab to see what the xhr is returning or use analert()orconsole.log()to see what the ASP is outputting as the result.Request.QueryString("yourargument") = "..."and only return whats needed.