Save as “file1.php”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){ $("#mybutton").click(function() { // alert("Hello"); var name1 = $('#boardname').attr("value"); // put attribute into variable // alert(name1); $('#content').load('changeboardname.php', { //content is the div area for a response to be given back //myfield: $('#boardname').val(), //jquery variable post infovar: name1 //javascript variable post }); //end load }); //end click }); //end ready </script> <input name="boardname" type="text" value ="Miketest" id = "boardname"> <div id="content"><input type="button" value ="change" id = "mybutton"> </div> |
Save as “runinbackground.php”
1 2 3 4 5 6 7 8 9 |
<?php include('cmdataconn.inc'); $name = mysql_real_escape_string($_POST['infovar']); echo $name; ?> |
or this way using a nicer button
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script> function change() { $('#load_tweets').load('record_count.php'); $('#load_tweets').fadeIn(500); } </script> <div id="load_tweets" style="display:none;"> </div> <input type="button" class="myclass" name="mybutton" value="mybutton" onclick="change()"> |