How to make javascript variable global

后端 未结 2 518
轻奢々
轻奢々 2021-01-12 02:56

I need to make this data variable global:

$.ajax({
    url: \"get_data.php\",
    cache: false,
    dataType: \'json\',
    data: {},
    succes         


        
2条回答
  •  走了就别回头了
    2021-01-12 03:31

    Any variable can be "made global" by attaching it as a property of the window.

    window.data = data;
    

    You can now access data as a global variable.

提交回复
热议问题