How to make javascript variable global

后端 未结 2 519
轻奢々
轻奢々 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

    Set a variable equal to what you wish data to be equal to. And when giving data its value, reference the variable. Like this:

    var obj = {};
    
    $.ajax({
        // ....
    
        data: obj,
    
        // ....
    });
    

提交回复
热议问题