[英]JQuery Ajax 500 (Internal Server Error)
I'm utilizing the jquery library to make an ajax call to a php file. 我正在利用jquery库对php文件进行ajax调用。 Everything was working fine when the path was relative like this:
当路径相对像这样时,一切都很好:
url:"fetch_term_grades.php",
But when I change the path like this: 但是当我改变这样的路径时:
url:"includes/ajax/fetch_term_grades.php",
I'm getting this error from the console: 我从控制台收到此错误:
jquery-2.2.3.min.js:4 POST http://localhost/SchoolMate/includes/ajax/fetch_term_grades.php 500 (Internal Server Error)
This is my ajax code: 这是我的ajax代码:
$.ajax({
url:"includes/ajax/fetch_term_grades.php",
method:"post",
data:{"term":term},
dataType:"text",
success:function(data){
$("#result").html(data);
$('#dataTable').DataTable();
//$('table').attr('id', 'dataTable');
}
});
url:"includes/ajax/fetch_term_grades.php"
this is still a relative path as I understand. 据我所知,这仍然是一条相对的道路。 Try with
/
at the beginning like /
+ actual path to that script in your filesystem. 尝试
/
在开头像/
+文件系统中该脚本的实际路径。 Maybe it is url:"/includes/ajax/fetch_term_grades.php"
也许是
url:"/includes/ajax/fetch_term_grades.php"
It depends on which location you are calling that script from. 这取决于您从哪个位置调用该脚本。 In your case the file that calls the scripts is located under the same folder which is includes/ajax/fetch_term_grades.php.
在您的情况下,调用脚本的文件位于包含/ ajax / fetch_term_grades.php的同一文件夹下。 If you want to call it using this url includes/ajax/fetch_term_grades.php you should put two layers up, ie: it should be side by side with the includes folder.
如果你想使用这个url include / ajax / fetch_term_grades.php调用它,你应该放两层,即:它应该与includes文件夹并排。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.