Ajax发布到目录中的php文件不起作用 [英] Ajax post to a php file in a directory not working

查看:64
本文介绍了Ajax发布到目录中的php文件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个项目的Ajax请求,但要使其正常工作,我遇到了很多问题,因此我有时会收到一些错误500(内部服务器错误),但最终一切正常,直到我想将脚本移到目录中为止./p>

这是我的Ajax作品:

  var xhr = getXMLHttpRequest();xhr.onreadystatechange = function(){if(xhr.readyState == 4&&(xhr.status == 200 || xhr.status == 0)){callback_like(xhr.responseText,接收);location.reload();}};xhr.open("POST","like.php",true);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");var data ="like =" +接收;xhr.send(data); 

这不起作用:

  var xhr = getXMLHttpRequest();xhr.onreadystatechange = function(){if(xhr.readyState == 4&&(xhr.status == 200 || xhr.status == 0)){callback_like(xhr.responseText,接收);location.reload();}};xhr.open("POST","script/like.php",true);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");var data ="like =" +接收;xhr.send(data); 

控制台中的错误消息:POST:'url'500(内部服务器错误)

我已经尝试设置目录的所有权限,但是没有任何变化.

谢谢

解决方案

内部服务器错误表示您的代码中可能存在错误.是否需要对其他文件的引用或包含的内容进行调整?如果找不到该文件,您的回复中将显示"404未找到".

在php中启用错误输出,以从php获取更详细的错误消息.

I'm using Ajax request for a project and i has lot of problem to make it working I sommetime receive some error 500 (Internal Server Error), but finally everything works until I wanted to move my scripts into a directory.

Here is my Ajax works :

    var xhr = getXMLHttpRequest();
    xhr.onreadystatechange = function() {
    if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
        callback_like(xhr.responseText, receive);
         location.reload();
      }
    };
    xhr.open("POST", "like.php", true);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    var data = "like=" + receive;
    xhr.send(data);

And this one doesn't work :

    var xhr = getXMLHttpRequest();
    xhr.onreadystatechange = function() {
    if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
        callback_like(xhr.responseText, receive);
         location.reload();
      }
    };
    xhr.open("POST", "script/like.php", true);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    var data = "like=" + receive;
    xhr.send(data);

Error message in the console : POST: 'url' 500 (Internal Server Error)

I already tried to set all the right to the directory but nothing change..

Thanks

解决方案

An internal server error means that there is probably an error in your code. Any references or includes of other files that need to be adjusted? If the file wouldn´t be found you´d get a 404 Not Found in your response.

Enable error output in php to get a more detailed error message from php.

这篇关于Ajax发布到目录中的php文件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆