Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 警告函数中的变量_Javascript - Fatal编程技术网

Javascript 警告函数中的变量

Javascript 警告函数中的变量,javascript,Javascript,我创建了一个包含参数的函数,并在另一个函数中警告响应,这就是为什么我创建了一个全局变量imageServer,并希望在AlertFunction函数中警告imageServer var imageServer ; function win(r) { console.log("Response = " + r.response); imageServer = r.response; } function AlertFunction() { al

我创建了一个包含参数的函数,并在另一个函数中警告响应,这就是为什么我创建了一个全局变量imageServer,并希望在AlertFunction函数中警告imageServer

var imageServer ;

function win(r) 
{
    console.log("Response = " + r.response);       
    imageServer = r.response;

}

function AlertFunction()
    {
    alert(imageServer);
    }
function win(r) 
{
console.log("Response = " + r.response);       
imageServer = r.response;
AlertFunction()
}

我想在AlertFunction函数中提醒r.response,但没有显示任何内容

您必须从win函数调用alert函数

var imageServer ;

function win(r) 
{
    console.log("Response = " + r.response);       
    imageServer = r.response;

}

function AlertFunction()
    {
    alert(imageServer);
    }
function win(r) 
{
console.log("Response = " + r.response);       
imageServer = r.response;
AlertFunction()
}

什么时候启动winr和AlertFunction?r是一个XHR对象吗?那么,console.log语句为您提供了预期的输出?你什么意思?什么都没有?这是否意味着警报为空或甚至没有弹出?警报不会弹出up@Katsudoka在这种情况下,您应该向我们展示调用函数AlertFunction的代码。到目前为止,你给了我们什么,我们只能猜测。