gpt4 book ai didi

php - 当 url 为 'abc' 时,ajax 正在工作,而当 urs 为 'abc/2' 时,ajax 在 laravel 中不起作用

转载 作者:行者123 更新时间:2023-11-29 21:02:15 26 4
gpt4 key购买 nike

<script>


$(document).ready(function(){

$(document).on('change','#compId',function () {


var username = $(this).val();
/*var token = $("input[name=_token]").val();
var dataString = 'username='+username+'&token='+token;
*/
var data1={username}

$.ajax({
type: "get",
url : 'depttBranch',
data : data1,

success : function(data){
$('#branchId').html(data);
alert(data);

},error : function(){
alert('out');
}
});

});
});//end of document ready function


</script>

最佳答案

这是因为您使用的是relative URLdepttBranch

这意味着在 http://example.com/abc 上,相对 URL depttBranch 将生成绝对 URL http://example.com/abc/depttBranchhttp://example.com/abc/2 上时,它会使 http://example.com/abc/2/depttBranch .

因此,您必须在 URL 中使用某种更精确的规范,例如相对于根,例如/abc/depttBranch。这样它就永远是http://example.com/abc/depttBranch

关于php - 当 url 为 'abc' 时,ajax 正在工作,而当 urs 为 'abc/2' 时,ajax 在 laravel 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37114070/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com