How would I pass data to an external script loaded with $.getScript()?

前端 未结 3 1928
青春惊慌失措
青春惊慌失措 2020-12-19 11:21

So I\'m trying to load a javascript remotely using jquery\'s $.getScript, but I\'m puzzled on how I can pass data to the external script.

I\'ve tried setting variabl

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-19 11:27

    Truly global variables will be accessible to your script. So, if they aren't, then it's probably because your variables that you think are global actually aren't. You can either move them to the top level scope or set them on the window object like Alexei suggested.

    There are other ways to share data.

    1) You can put an id on the

提交回复
热议问题