Here is my code.
这是我的代码。
<head>
<script>
var myGlobal ={};
</script>
</head>
<body>
$(function ()
{
$.ajax({
url: 'test.php',
data: "",
dataType: 'json',
success: function(data)
{
var vname = data.name;
my_global.push(data.name);
}
alert('The user selected: ' + my_global.newval); // i will use this value(vname value)
I would like to use VNAME
value in other function..
我想在其他函数中使用VNAME值..
1 个解决方案
#1
Put all the code in the same script tags. What you wrote won't even work. The ajax code will just be displayed as text and not handled as script.
将所有代码放在相同的脚本标记中。你写的东西甚至都不起作用。 ajax代码将仅显示为文本而不作为脚本处理。
#1
Put all the code in the same script tags. What you wrote won't even work. The ajax code will just be displayed as text and not handled as script.
将所有代码放在相同的脚本标记中。你写的东西甚至都不起作用。 ajax代码将仅显示为文本而不作为脚本处理。