我试图在浏览器中使用Webdis和jQuery显示Redis数据。 Redis和Webdis正在从命令行(使用curl)正常工作,但我无法获取要在浏览器中显示的数据。 Webdis以JSON响应,并且curl响应为{“GET”:“103”}。任何人都知道问题?欢迎提出任何改进建议。谢谢!在浏览器中显示Webdis响应
的代码如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- load JQuery from Google API -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<!-- This is the jQuery template for the JSON returned by Webdis -->
<script id="webdisTemplate" type="text/x-jquery-tmpl">
<li>${GET}</li>
</script>
<!-- jQuery Ajax request through Webdis that feeds the Redis data into the template -->
<script type="text/javascript">
$(document).ready(function()
{
$.ajax({
url: "http://127.0.0.1:7379/GET/value",
data: "format=json",
dataType: "json",
success: function(data)
{
$("#webdisTemplate").tmpl(data.items).appendTo("#placeholder");
}
});
});
</script>
<title>Webdis Test</title>
</head>
<body>
<h4>Value:</h4>
<ul id="placeholder"></ul>
</body>
</html>
您是否试图将“format = json”传递给您的服务器方法?如果不是,则“data:”属性表示您想要传递的参数,并且必须由服务器方法定义。 – 2012-02-03 01:58:53
这确实看起来相当错误。发布您的PRECISE curl命令行。 – bmargulies 2012-02-03 02:00:10