<script text="text/javascript" src="http://o.aolcdn.com/dojo/1.3/dojo/dojo.xd.js" djConfig="parSEOnLoad:true,isDebug:true" ></script> <script type="text/javascript"> //How are we supposed to kNow what else to include in the dojo thing? like query? dojo.addOnLoad(function(){ console.log("hi"); dojo.xhrPost({ url: "http://www.scrapbookingsuppliesrus.com/catalog/layout",//who kNows how to set relative urls? handleAs: "json",//get json data from server load: function(response,ioArgs){ console.log("got"); console.log(response); //helps with the debugging return response; //that way goods should be a very large array of the data we want },error: function(response,ioArgs){ console.log("nope didn't make it",response+' '+ioArgs); //helps with the debugging return response; //who kNows what this does } //last item,thus no extra comma }); }); </script>
但没有任何反应.虽然我在这,但究竟是什么响应和ioArgs变量.它们应该神奇地是对我认为已经特别定义的请求的响应.但是,谁知道呢.此外,我想在每次尝试之后它会在加载或错误中触发某些东西,但是唉.
曾经有一个错误,我将被禁止的uri,但然后firebug会引用一个非常大的dojo脚本,在那里无法分辨为什么它被打破.你们其他人在开发什么样的环境?
解决方法
让我们先从非常简单的开始.
在开发时,您希望使用Dojo的“未压缩”版本,可以通过将.uncompressed.js附加到正在使用的Dojo库的路径来找到:
http://o.aolcdn.com/dojo/1.3/dojo/dojo.xd.js.uncompressed.js
如果它在core-Dojo中,这将使得更容易看到什么中断.
接下来是djConfig参数.我很确定Dojo可以处理一个字符串,但传统上它已经被一个对象定义了,所以,一旦你包含了你的Dojo库:
<script src="path to dojo"></script>
<script> djConfig = { parSEOnLoad: true,isDebug: true }; </script>
接下来最简单,我使用IntelliJ JIDEA进行开发,它具有内置的Dojo代码感,使生活更轻松.否则,标准包,Firefox Firebug.
复杂的东西:
您似乎正在使用XHR方法请求数据,希望您知道这意味着您的脚本和被访问的数据必须位于同一个域中,否则您将遇到安全性错误.怎么解决这个问题?您使用称为跨域脚本的技术,dojo也通过dojo.io.script.get功能支持.
更复杂的东西:
Dojo使用称为“延迟”对象的东西.这意味着一旦创建了对象,请求实际上就不会出现,而是当你要求它出去时它会消失,这就是“延迟”的概念,你将一段代码的执行推迟到晚点.在你的情况下,这个问题的解决方式是这样的:
var deferred = dojo.xhrPost({ url: "http://www.scrapbookingsuppliesrus.com/catalog/layout",//who kNows how to set relative urls? handleAs: "json" //get json data from server }); if(deferred) { deferred.addCallback(function(response){ console.log("got"); console.log(response); //helps with the debugging return response; //that way goods should be a very large array of the data we want }); deferred.addErrback(function(response){ console.log("nope didn't make it",response+' '+ioArgs); //helps with the debugging return response; //who kNows what this does }); }
这应该可以解决了.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。