I want to enter value, to input field so when I leave the input field by clcking out side from the input field I will run the ajax code and send the value input dataString
to same file which in this case cald ajax.php.
Thanks
my code:
$(document).ready(function()
{
var dataString;
$("valueforajax").mouseleave(function() {//when we leave the field.
alert('test it is mouseup ');
dataString=$("#valueforajax").val();
alert(dataString);
if ("" = dataString){//it is mean that input field not empty
$.ajax({
type: "POST",
url: "../../ajax.php",
data: dataString,
cache: false,
success: function(html)
{
alert("There is submited sucsses");
}
});//ajax
}//if
});//mouseup
});//ready
ajax.php
<?php
if (isset($_POST['dataString'])){
echo ("dataString not empty:= ".$_POST['dataString']);}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="./public/stylesheets/stylesheets.css" >
<script type="text/javascript" src="./public/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="./public/js/ajax.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<title>mange panel</title>
</head>
<body>
<br>Type value for test in ajax<input id="valueforajax" type=text name='ajaxtest'>
</body>
</html>