Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery-ajax,url属性没有';我不能正常工作_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript jQuery-ajax,url属性没有';我不能正常工作

Javascript jQuery-ajax,url属性没有';我不能正常工作,javascript,jquery,ajax,Javascript,Jquery,Ajax,我使用这段琐碎的代码,但它不能正常工作(在我看来): 控制台中的输出为: index.php/table/show/#summary 但ajax请求已发送到: http://test.loc/st_base/index.php/table/show/ 如果您使用的是相对url,则会将index.php/table/show/“+this.hash附加到脚本的当前位置 您的脚本似乎位于“” 请尝试指定完整url,以“…”开头。不幸/幸运的是,没有问题。一切正常。浏览器只是不向服务器发送哈希。

我使用这段琐碎的代码,但它不能正常工作(在我看来):

控制台中的输出为:

index.php/table/show/#summary
但ajax请求已发送到:

http://test.loc/st_base/index.php/table/show/

如果您使用的是相对url,则会将
index.php/table/show/“+this.hash
附加到脚本的当前位置

您的脚本似乎位于“”


请尝试指定完整url,以“…”

开头。不幸/幸运的是,没有问题。一切正常。浏览器只是不向服务器发送哈希。 如果确实需要传递,请将其放入数据:

var url = "index.php/table/show/";
var hashOnly = this.hash;
$.ajax({
    type: "POST",
    data: {myhash: hashOnly},
    url: url,
    dataType: 'json',
    success: function(response)
    {
        if(response.status == 'ok')
        {
        }
    }
});
尝试使用var url=“/index.php/table/show/”
var url = "index.php/table/show/";
var hashOnly = this.hash;
$.ajax({
    type: "POST",
    data: {myhash: hashOnly},
    url: url,
    dataType: 'json',
    success: function(response)
    {
        if(response.status == 'ok')
        {
        }
    }
});