Hey all,
I'm *trying* to use AJAX to update/reload a DIV on a page, but I'm running into a snag. Bare with me, JS is very new to me.
I have a a PHP page that creates a table of form cells. The cells are populated with data that comes from a SQL database. When I click on a cell and change the value, that cells new value is updated in the database. Where I'm struggling is, reloading that table on the page.
Here is a general snip-it of what I'm working with:
I'm using $('div#table').load("index.php #blah"); which works only once. Unfortunately, it will not continuously reload/execute the JS on the next mouseleave(). If I do a window.location.reload(true); then the whole page refreshes and everything is great...but then what is the point of ajax if everything reloads, right? (note: before I do the mouseleave() I'm doing a click() for the <input>).
I've tried $('div#blah').load("index.php #blah"); and all this does is double the div with the same ID. Any ideas? Hopefully this is clear enough...
I'm *trying* to use AJAX to update/reload a DIV on a page, but I'm running into a snag. Bare with me, JS is very new to me.
I have a a PHP page that creates a table of form cells. The cells are populated with data that comes from a SQL database. When I click on a cell and change the value, that cells new value is updated in the database. Where I'm struggling is, reloading that table on the page.
Here is a general snip-it of what I'm working with:
Code:
<div id="table">
<div id="blah">
<?php include("tableBuilder.php"); ?> <---this is what builds the table
</div>
</div>
<script type='text/javascript'>
// some JS code to parse info
$('#theID).mouseleave(function() {
//update SQL database using POST - works
$('div#table').load("index.php #blah"); <--- this is my problem
//window.location.reload(true); <---this is works...but then whats the point of using ajax?
});
</script>
I'm using $('div#table').load("index.php #blah"); which works only once. Unfortunately, it will not continuously reload/execute the JS on the next mouseleave(). If I do a window.location.reload(true); then the whole page refreshes and everything is great...but then what is the point of ajax if everything reloads, right? (note: before I do the mouseleave() I'm doing a click() for the <input>).
I've tried $('div#blah').load("index.php #blah"); and all this does is double the div with the same ID. Any ideas? Hopefully this is clear enough...
Last edited: