为什么同样的js代码逐行输入就能用,全输进去就报错
本帖最后由 hinagikumoe 于 2017-12-19 23:06 编辑为什么我在浏览器控制台一行一行输入没问题,直接全部贴进去显示错误
var list = new Array();
var d = new Date();
var a;
var date = d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate();
var lastLabel = "";
var nextLabel = "";
do
{
a=$.get(geturl(lastLabel,nextLabel,date),liteData);
lastLabel=JSON.stringify(a.responseJSON.lastLabel);
nextLabel=JSON.stringify(a.responseJSON.nextLabel);
}while(nextlabel!="")
function geturl(last,next,d)
{
return "http://e.waimai.meituan.com/v2/order/history/r/query?getNewVo=1&wmOrderPayType=2&wmOrderStatus=-2&sortField=1&startDate="+d+"&endDate="+d+"&lastLabel="+escape(last)+"&nextLabel="+escape(next);}
function liteData(data,status)
{
list=list.concat(data);
}Uncaught TypeError: Cannot read property 'lastLabel' of undefined
at <anonymous>:11:44
(anonymous) @ VM117:11
错误显示在11行,但是明明数据是有的,直接输入也能自动补全出来 jquery的框架吗,以前我用jquery都是异步回调,现在变成默认同步请求了? 为什么要这么搞?不嫌累吗 激萌的萝莉 发表于 2017-12-19 23:21
为什么要这么搞?不嫌累吗
因为不会…… http://www.w3school.com.cn/jquery/ajax_get.asp
如果是jquery的话,请在回调函数里面写后续处理 hgfdsa 发表于 2017-12-19 23:24:34
http://www.w3school.com.cn/jquery/ajax_get.asp
如果是jquery的话,请在回调函数里面写后续处理 ...解决了,谢谢
昨天在返回的数据里没看到,今天仔细一看居然找到了
自己眼瞎麻烦大家了
-- 来自 能看大图的 Stage1官方 Android客户端 说白了就是js1是异步的,尤其是$.get
页:
[1]