php - when url is 'abc' ajax is working and when urs is 'abc/2' ajax is not working in laravel -
<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>
it's because using relative url, depttbranch
.
this means on http://example.com/abc
relative url depttbranch
make absolute url http://example.com/abc/depttbranch
while on http://example.com/abc/2
make http://example.com/abc/2/depttbranch
.
therefore have use kind of more exact specification in url, example relative root, e.g. /abc/depttbranch
. way http://example.com/abc/depttbranch
.
Comments
Post a Comment