johnnys Posted November 7, 2014 Share Posted November 7, 2014 (edited) I am creating a library app (personal dev) and have ran into some trouble. I'm very new to Ajax and Php I have a page named addEntryISBN which shows the results of a user search in a div named #results. I want to post the contents of #results to my database. The contents of #results comes from a page named searchISBN. What is the most effective way of doing this? My code so far is aas follows; addEntryISBN.php $(document).ready(function() { $('form').on('submit', function (e) { e.preventDefault(); $.ajax({ type: 'post', url: 'searchIsbn.php', data: $('form').serialize(), success: function (result) { $('.result').html(result); } }); return true; }); }); <div class="result"</div> searchISBN.php <?php echo '<table class="table">'; echo '<tr>'; echo '<h3>Book Info</h3>'; echo '</tr>'; echo '<tr>'; echo '<td> Title </td>'; echo '<td>' . $title . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td> Page Count </td>'; echo '<td>' . $pageCount . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td> Publish Date </td>'; echo '<td>' . $publishDate . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td> Description </td>'; echo '<td>' . $description . '</td>'; echo '</tr>'; echo '</table>'; echo '<form><input id="add_isbn" method="post" type="submit" value="Add This Book" /></form>'; } ?> I hope this makes sense! Any help is much appreciated. J Edited November 7, 2014 by johnnys Quote Link to comment https://forums.phpfreaks.com/topic/292344-send-div-results-via-ajax/ Share on other sites More sharing options...
Solution Barand Posted November 7, 2014 Solution Share Posted November 7, 2014 Then you need to put $title, $publishdate etc into form input fields, not just in table cells 1 Quote Link to comment https://forums.phpfreaks.com/topic/292344-send-div-results-via-ajax/#findComment-1496049 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.