Main.php
<script>
$(document).ready(function(){
searchUser();
});
function searchUser() {
alert("aaaaaaaa");
var data = $("#user-search-form").serialize();
$.ajax({
type: "POST",
url: "test.php",
data: data,
success: function(response) {
alert("bbbbbbbb");
}
});
alert("cccccccc");
return false;
}
test.php
<?php echo "testing 1234" ?>
Directory:
- phpturtorial/admin/main.php
- phptutorial/admin/test.php
I am calling php function using ajax but not working. My code able to alert “aaaaaaaa” and “cccccccc” but cannot alert “bbbbbbbb”. Any idea ? is it related to my incorrect path ?
2
Answers
phpturtorial/admin/main.php
andphptutorial/admin/test.php
are in two different directories.Hence why it is not able to locate
test.php
.Change
url: "test.php"
tourl: "/phptutorial/admin/test.php"
With the Given Information:
Case 1:
Case 2: