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

WBOY
Release: 2016-06-21 09:31:24
Original
1608 people have browsed it

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


回复讨论(解决方案)

修改类似如下试试

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

修改类似如下试试

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


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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template