Home  >  Article  >  Web Front-end  >  为什么这里返回的函数值为underfined?_html/css_WEB-ITnose

为什么这里返回的函数值为underfined?_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 09:31:241606browse

上一句效果出来了,怎么返回的不是true是underfined呢?


回复讨论(解决方案)

修改类似如下试试

function fn(){	var flag=false;	$.get('test.php',function(data){		if(data==1)			flag=true;		else			flag=false;	})	return flag;}

修改类似如下试试

function fn(){	var flag=false;	$.get('test.php',function(data){		if(data==1)			flag=true;		else			flag=false;	})	return flag;}


这提醒我了,返回的值是到function(data)那里了,并没有到我alert的函数那里,所以要定个全局变量去判断,你这方法是对的!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn