Assigning values to variables via ajax loaded script
Assigning values to variables via ajax loaded script
I am trying to assign a value to a java variable inside the script that I am calling via ajax but once the call is over it shows variable as undefined:
$.ajax({
type: "GET",
url: "getdata.js",
dataType: "script",
success: function(){ alert( typeof data_array ); },
error:function(){ alert("WTH"); }
});
getdata.js:
<script type="text/javascript">
data_array=[1,2,3]
</script>