使用.htaccess重写后,Jquery无法正常工作

问题描述:

I have tried to use .htaccess but my rewriting work fine but note ajax codes there just froze not doing any thin is this because rewriting?

MY .Htaccess Code

#Turn Rewriter on
RewriteEngine on



RewriteRule ^testthis test/test.php [Nc,L] 

My Php Code

<!DOCTYPE html>
<html>
<head>
    <title>THaalinda</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>    
</head>
<body>

Testing 


<script src='testthis/content/test.js' type="text/javascript">


</script>
</body>
</html>

My Jquery Separate file

$(document).ready(function(){
    alert('Thaalinda');
})

in here test.js located at (./content/test.js/) before re-Writing it's working perfectly after that it's not working at all

我曾尝试使用.htaccess但我的重写工作正常但注意ajax代码只是冻结没有做任何薄是 这是因为重写? p>

我的.Htaccess代码 strong> p>

  #Turn Rewriter on 
RewriteEngine on 
 \  n 
 
RewriteRule ^ testthis test / test.php [Nc,L] 
  code>  pre> 
 
 

我的Php代码 strong> p> &lt;!DOCTYPE html&gt; &lt; html&gt; &lt; head&gt; &lt; title&gt; THaalinda&lt; / title&gt; &lt; script src =“https://ajax.googleapis。 COM / AJAX /库/ jquery的/ 3.1.1 / jquery.min.js“&GT;&LT; /脚本&GT; &lt; / head&gt; &lt; body&gt; Testing &lt; script src ='testthis / content / test.js'type =“text / javascript”&gt; &lt; / script&gt; &lt; / body&gt; &lt; / html&gt; code> pre>

我的Jquery单独文件 strong> p> \ n

  $(document).ready(function(){
 alert('Thaalinda'); 
})
  code>  pre> 
 
 

在这里 test.js位于(./content/test.js/)之前重新编写它完全正常工作之后它根本不起作用 p> div>

You need to use absolute path in your url of ajax instead of relative path. Change this var link = "./content/php/updatequantity.php?quan="+value+"&id="+updateId; to var link = "/content/php/updatequantity.php?quan="+value+"&id="+updateId;