javascript - How can I load a php webpage and send that php webpage a POST without refreshing? -


i have following code:

<body>     <ul id = "nav">         <textarea rows="0" cols="0" name="textboxstuff" maxlength="0" value="">10</textarea>         <li><a href="test2">home</a></li>         <li><a href="test3">about us</a></li>         <li><a href="test4">contact</a></li>     </ul>     <div id="content">     <script src="jquery.js"></script>     <script src="general.js"></script>     </div> </body> 

when click on of links load general.js has following code:

$(document).ready(function() {     $('#content').load('content/test1.php');     $('ul#nav li a').click(function (){         var page = $(this).attr('href');     $('#content').load(page + '.php');         return false; }); }); 

this load content test2.php, or test3.php, or test4.php. depends on link press. load content without refreshing webpage want. however, in test2.php file, want output written in textbox on main page.

this code in test2.php:

<?php     $textboxstuff = $_post['textboxstuff'];     echo $testboxstuff;     echo '<h1>home</h1>'; ?> 

so word "home" showing when click home on main page, don't know how send $_post['textboxstuff']; test2.php file. $_post['textboxstuff'] should equal whatever inside textarea on main webpage. question if knows how send data textbox mainpage test2.php file without refreshing webpage, using jquery.

you need add second parameter .load() method tell jquery send server.
eg:

$('#content').load(page + '.php', {        textboxstuff: document.getelementsbyname("textboxstuff")[0].value }); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -