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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -