Ajax 在 WAMP 的虚拟主机中调用不工作

Ajax call not working in Virtual Host in WAMP

我正在做一个 CI 项目,为此,我在 wamp 中创建了一个虚拟主机。它运作良好。但主要问题现在开始了。每当我调用 Ajax 请求它 with/without 给出 ajax post URL 它显示一个结果。不知道是什么问题..

我正在单击忘记密码 link,然后它会打开一个带有忘记密码表单的弹出窗口。

没有URL

$.get('').done(function (msg) {
                console.log('Yes');
                console.log(msg);
            }).fail(function (xhr, status, error) {
                console.log(xhr);
                console.log(status);
                console.log(error);
            });

结果

在这种情况下,我得到了结果(它在 "done" 中)但给了我整个登录页面 HTML。

和URL

$.get('http://fileupload.local/login/getresetpassword').done(function (msg) {
                console.log('Yes');
                console.log(msg);
            }).fail(function (xhr, status, error) {
                console.log(xhr);
                console.log(status);
                console.log(error);
            });

结果

我尝试了太多超过 google 的解决方案,但找不到合适的解决方案。现在正在扯头发,想把它完成

我觉得你的 Ajax 还不错。它应该工作。我有一些建议:

  • 直接在浏览器中打开Url:http://fileupload.local/login/getresetpassword。我们会看到结果(好像return整个页面?)

  • 检查服务器代码。我认为这是我们的主要问题。 return 会不会是 JSON 类型?

这是一个配置问题。它通过将 $config['uri_protocol'] = 'QUERY_STRING'; 更改为 $config['uri_protocol'] = 'REQUEST_URI';

来解决