AJAX POST SCRIPT
________________________________________________________
index.php
________________________________________________________
<!DOCTYPE html>
<html>
<head>
<title>AJAX POST</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function($){
var text1 = $('#text_id1');
var text2 = $('#text_id2');
$('#button_submit').click(function(){
jQuery.ajax({
url: 'ajax_page.php',
type: 'post',
data: 'text1=' + text1.val() + '&text2='+text2.val(),
success: function(results){
$("#text_id3").val(results) ;
}
});
});
});
</script>
</head>
<body>
<h2>AJAX POST</h2>
<input type="text" name="text1" id="text_id1" />
<input type="text" name="text2" id="text_id2" />
<input type="text" name="text3" id="text_id3" />
<button id="button_submit">Get Result</button>
</body>
</html>
________________________________________________________
ajax_page.php
________________________________________________________
<?php
$text1 = $_POST["text1"]; $text2 = $_POST["text2"];
echo $text = $text1 + $text2;
?>
Comments
Post a Comment