I have a container, the content was loaded with AJAX.
Inside that container, I have a form, and the plan is to submit the form with AJAX.
I am currently testing the code if this works, but the result turned out to be unexpected results.
Here is the form submission code:
$("#in-quiz-answer").click(function(e) {
e.preventDefault();
var ans = $(".answer-rad").val();
var addr = $("#in-address").val();
$.ajax({
type: 'POST',
url: 'pages/bin/quizprocess.php',
data: "ans=123",
success: function(data) {
alert(data);
},
error: function(a, b, c) {
alert("Error pada koneksi: " + a + ", " + b + ", " + c);
}
});
return false;
});
In quizprocess.php i only have echo $_POST['ans'];
for testing purposes, but the ajax success function alerts a long html code (my whole page code) instead of just what I expected "123". Can anyone explain why is this happening?
[EDIT] Seems that my problem is it is not even requesting to quizprocess.php but the ajax success. I still don't have any workaround on this.
[SOLUTION] I have found the problem, it is the url rewriteengine from my htaccess that caused the problem. Thank you very much for all the help and comments