newrow

POST Requests with jQuery

An HTTP POST request is simply an HTTP request that can have any type of data attached to it. You're probably familiar with their use when submitting web forms. This is quite easy...
this is the method syntax we gonna use here:
$(selector).post(URL,data,function(data,status,xhr),dataType)
Here the submit page:
//load jquery file
<script src="http://code.jquery.com/jquery-latest.js"></script>
//jQuery submit function written here
<script type="text/javascript" language="javascript">
function submitIt() {
$.post("submitdatafile.php", { pwd: document.getElementById("tbox").value } );
}
</script>
//HTML code
<input type="password" name="tbox" id="tbox">
<input type="button" name="bt" id="bt" value="Submit" onclick="javascript:submitIt()">

you can use that posted data on submitdatafile.php
<?php
// you can use posted data here..
echo $_POST['pwd'];
?>
view raw post page.php hosted with ❤ by GitHub
You can get more information via jQuery home page.


No comments:

Post a Comment