This question is not Duplicate. Could you get it working and prove that it is duplicate ???
How can I submit the form below without submitting the page.
The Action in the below form has RESTful POST method.
e.g of consuming that API :
http://s22.postimg.org/79wp8rbv5/Capture.png
So, I have this static page. I need to submit the form without the page gets submitted. Any idea about that ?
<html>
<head>
<!-- jQuery v1.11.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license -->
<script src="jquery.js"></script>
<script>
$(document).onload(function() {
$("#submit-form-button").onclick(function() { submitForm(); });
});
function submitForm() {
$.ajax({
type: "POST",
url: "https://apex.oracle.com/pls/apex/somefeto/hr/emp/",
data: { ENAME: $_POST['ENAME']},
success: function() {
alert("FORM SUBMITTED!");
},
dataType: 'html'
});
};
</script>
</head>
<body>
<form action= "https://apex.oracle.com/pls/apex/somefeto/hr/emp/" method="POST">
Employee: <input type="text" name="ENAME">
<a href="#" id="submit-form-button">SUBMIT</a>
</form>
</body>
</html>
After two hours, I manage to do it:
<html>
<head>
<!-- jQuery v1.11.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license -->
<script src="jquery.js"></script>
<script>
$(document).ready(function() {
$("#submit-form-button").click(function() { submitForm(); });
});
function submitForm() {
var x = $("#ENAME").val();
$.ajax({
type: "POST",
url: "https://apex.oracle.com/pls/apex/somefeto/hr/emp/",
data: { ENAME: x },
success: function() {
alert("FORM SUBMITTED!");
},
dataType: 'html'
});
};
</script>
</head>
<body>
<form action= "https://apex.oracle.com/pls/apex/somefeto/hr/emp/" method="POST">
Employee: <input id="ENAME" type="text" name="ENAME">
<a href="#" id="submit-form-button">SUBMIT</a>
</form>
</body>
</html>