如何使用dojo进行休息服务?

时间:2013-08-08 09:27:21

标签: rest dojo

任何人都可以告诉我如何使用dojo.io.script调用休息服务。

try {
  dojo.io.script.get({
    url: "http://search.twitter.com/search.json",
    content: {
      q: "#dojo"
    },
    callbackParamName: "callback"
  }).then(function(data) {

  });
} catch (e) {
  alert(e);
}

我尝试使用上面的代码,但我没有得到回复。可能是什么问题?

1 个答案:

答案 0 :(得分:1)

你可以像下面这样调用HTTP GET:

// The "xhrGet" method executing an HTTP GET
dojo.xhrGet({
    // The URL to request
    url: "get-message.php",
    // The method that handles the request's successful result
    // Handle the response any way you'd like!
    load: function(result) {
        alert("The message is: " + result);
    }
});

有关详细信息,请在此处查看documentation

另一个例子是here

相关问题