ajax更改全局javascript变量不起作用

时间:2014-08-11 07:07:15

标签: javascript ajax

我在jsp文件中定义了一个变量,然后在包含* .js文件的ajax函数中我改变了变量,但它不起作用。 在Ajax中,我设置了 async:false 。 我的jsp代码是:

<script type='text/javascript' > 
   window.leave=1;
</script>
 <script src="${ctxPath}/js/registerchange/registerchange.js" type="text/javascript">      </script>
....
<!--then I call the function change() in registerchange.js -->

registerchange.js中的change()函数是

$.ajax({
 type: "POST",
 async: false,
 url:projectpath+"/registerChange.do?cmd=update",
 data:{"str":str,"changeBefore":changeBefore,"fk_ChangeProject":fk_ChangeProject,"sbdNum":sbdNum,"ifShow3":ifShow3},
 contentType:"application/x-www-form-urlencoded; charset=UTF-8",
 success:function(data){
     window.leave = 2;
 } });

调用ajax函数后,在jsp文件中我使用window.leave变量,它仍然是1。 thx。

。任何建议都会有所帮助

0 个答案:

没有答案