在回调函数前边的一个函数里执行了return

mmqw 2013-07-20 02:19:11
在回调函数前边的一个函数里执行了return,还能进入回调函数吗?
...全文
378 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
街头小贩 2013-07-20
  • 打赏
  • 举报
回复
引用 11 楼 mmqw1122 的回复:
[quote=引用 10 楼 xiaofanku 的回复:] 不太明白。你大体写一个伪代码瞧瞧
Query.ajax({ url: "/Ajax/AjaxSiteStatus.ashx?rnd=" + Math.random(), type: "get", success: function (status) {}}); return;[/quote] 上面的代码已经注册了请求成功后的回调了.像下面这种complate回调会不被调用

			var xhr=$.ajax({
				type: "GET",
				url:'/ajax.php?a=check_comment',
				data:{ comment_id: value}
			}).success(function(date){
				try{
					var mj=jQuery.parseJSON(date);
					if(mj!==null){
						$('#comment_pid').val(mj.id).next('textarea').html('
引用
'+mj.message+'
').focus(); } }catch(exception){ eval(date); } }); return; xhr.complete(function(){ alert('xhr is complate'); });
mmqw 2013-07-20
  • 打赏
  • 举报
回复
引用 10 楼 xiaofanku 的回复:
不太明白。你大体写一个伪代码瞧瞧
Query.ajax({ url: "/Ajax/AjaxSiteStatus.ashx?rnd=" + Math.random(), type: "get", success: function (status) {}}); return;
mmqw 2013-07-20
  • 打赏
  • 举报
回复
谢了
街头小贩 2013-07-20
  • 打赏
  • 举报
回复
不太明白。你大体写一个伪代码瞧瞧
mmqw 2013-07-20
  • 打赏
  • 举报
回复
引用 6 楼 xiaofanku 的回复:

			var xhr=$.ajax({
				type: "GET",
				url:'/ajax.php?a=check_comment',
				data:{ comment_id: value}
			});
			return;
			xhr.done(function( date ) {
				try{
					var mj=jQuery.parseJSON(date);
					if(mj!==null){
						$('#comment_pid').val(mj.id).next('textarea').html('
引用
'+mj.message+'
').focus(); } }catch(exception){ eval(date); } });
这种是不会执行回调的
可以算是这种情况了,我擦了我说调了一天怎么就是不进回调函数,弄死我了
mmqw 2013-07-20
  • 打赏
  • 举报
回复
引用 5 楼 xiaofanku 的回复:
在进入success之前,执行了一次return,还能进入success吗? re: 在哪执行的呀?
另一个函数里,在这个函数结束后,会进入一个加载判断函数,执行了一次return
街头小贩 2013-07-20
  • 打赏
  • 举报
回复

			var xhr=$.ajax({
				type: "GET",
				url:'/ajax.php?a=check_comment',
				data:{ comment_id: value}
			});
			return;
			xhr.done(function( date ) {
				try{
					var mj=jQuery.parseJSON(date);
					if(mj!==null){
						$('#comment_pid').val(mj.id).next('textarea').html('
引用
'+mj.message+'
').focus(); } }catch(exception){ eval(date); } });
这种是不会执行回调的
街头小贩 2013-07-20
  • 打赏
  • 举报
回复
在进入success之前,执行了一次return,还能进入success吗? re: 在哪执行的呀?
mmqw 2013-07-20
  • 打赏
  • 举报
回复
引用 3 楼 xiaofanku 的回复:
ajax?你贴一下代码我瞧瞧
jQuery.ajax({ url: "/Ajax/AjaxSiteStatus.ashx?rnd=" + Math.random(), type: "get", success: function (status) {}}); 在进入success之前,执行了一次return,还能进入success吗?
街头小贩 2013-07-20
  • 打赏
  • 举报
回复
ajax?你贴一下代码我瞧瞧
mmqw 2013-07-20
  • 打赏
  • 举报
回复
引用 1 楼 xiaofanku 的回复:
return后面的代码不会执行,这个要看你回调函数在什么情况下触发了
比如说我读取后台的数据,然后在获取到数据进入回调函数之前,在另一个函数里执行了一次return,我还能进入这个回调函数吗?
街头小贩 2013-07-20
  • 打赏
  • 举报
回复
return后面的代码不会执行,这个要看你回调函数在什么情况下触发了

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧