【发布时间】:2011-10-25 17:07:22
【问题描述】:
我正在使用以下代码从我的服务器检索 json 格式的值:
$(document).ready(function(){
$.getJSON("http://127.0.0.1/test/echo.php?jsoncallback=?", {
value: 'hello',
}, function(data){
$('#div').html(data.test);
}); });
如您所见,$.getJSON 网址现在是:http://127.0.0.1/test/echo.php?jsoncallback=?
但我更喜欢:http://127.0.0.1/test/echo/
在我的服务器上,我正在使用以下 mod 重写代码:
RewriteRule 上的 RewriteEngine ^test/echo/([^/.]+) test/echo.php?value=$1 [L]
当我在浏览器中输入 URL (http://127.0.0.1/test/echo/hello) 时,一切正常,但我想知道如何在 $.getJSON 请求中使用干净的 url .因为由于某种原因,我喜欢的网址现在不起作用。
【问题讨论】:
标签: javascript jquery json mod-rewrite getjson