This is index.html
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="jsn.js">
</script>
</head>
<body>
<form >
FirstName:<input type="text" id="first" >
LastName:<input type="text" id="last" >
<input type="Submit" value="not working">
</form>
<br>
<div id="display"></div>
</body>
</html>
and this is jsn.js
$(function(){
$('form').submit(function(e){
e.preventDefault();
$.ajax({
url: 'send.php',
type: 'post',
data: {'action': 'follow'},
success: function(data, status) {
if(data == "ok") {
$('#display').html("<p>Saved!</p>");
}
},
error: function(xhr, desc, err) {
console.log(xhr);
console.log("Details: " + desc + "\nError:" + err);
}
}); // end ajax call
});
});
and this is send.php
<?php
if($_POST['action'] == "follow") {
echo "ok";
}
?>
I’m testing it on firefox.
console.log is not giving the necessary info its only displays
“Use of getPreventDefault() is deprecated. Use defaultPrevented instead.”
other then that I want to how to submit form input values.
one more thing what is the AngularJs way to do this?