我知道ajax和返回变量的问题,我在stackoverflow中读到这个,我知道我必须使用回调函数,但在我的情况下没有工作,当然我做错了
我的代码是这样的:
var id_user=get_id_user_login();//undefined??????????
function get_id_user_login(){
FB.api(
'/me',
{fields:'id'},
function(response){//callback
console.log(response.id);//OK
return response.id;
}
);
};
Run Code Online (Sandbox Code Playgroud) 我有这个地址:
Grimshaw Lane, Bollington, Macclesfield SK10 5JB,
Run Code Online (Sandbox Code Playgroud)
寻找这个地址,我得到了这个(来自API):
Bollington Wharf, Grimshaw Lane, Bollington, United Kingdom
Run Code Online (Sandbox Code Playgroud)
我知道如何工作preg_match,但我相信无论如何必须比较两个类似的文本(相似,不一样),并确定它们是否是相同的地址(即使它们有点不同).