How do I give JavaScript variables data from ASP.NET variables?

后端 未结 9 1043
野趣味
野趣味 2020-11-28 08:46

I have created a SCORM API for our LMS and right now I am using hard coded userID and courseID variables (variables that reference things in the database). I need to pass th

相关标签:
9条回答
  • 2020-11-28 09:29

    In Passing .NET Server-Side Data to JavaScript, I list various approaches, including:

    1. Fetching Data by Making an AJAX Request
    2. Loading Data Through an External JavaScript File
    3. Opening a Persistent Connection with SignalR
    4. Attaching Data to HTML Elements
    5. Assigning Data Directly to a JavaScript Variable
    6. Serializing a .NET Object into a JavaScript Literal
    0 讨论(0)
  • 2020-11-28 09:32

    You can also use HTTP cookies. That approach is nice if you need to pass values the other direction as well.

    0 讨论(0)
  • 2020-11-28 09:33

    I am in the process of doing the same thing. I am just passing whatever values I may need upon initialization and such in the API object's constructor. I have not seen any requirements as to how the API object can be created, just how it is located in the SCO's code.

    0 讨论(0)
提交回复
热议问题