How to pass data to callback?
See original GitHub issueHi, probably very naive question. How do I pass data to the callback method?
I would like to make an AJAX call to an API on select and clear methods, but I am trying to figure out how to pass information necessary for the API call.
Since content can be generated automatically, I usually set ids for ajax calls in the elements. For example: <button id="myButton" data-id="10"> </button>
and then I can access that id in jquery. But I can’t do this with bar-rating since it replaces the default select element.
Any hints would be appreciated!
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
JavaScript: Passing parameters to a callback function
Just use the bind() function which is primarily used to set the this value. However, ...
Read more >JavaScript Passing parameters to a callback function
In this article, we will see how to pass parameters to a callback function. Firstly let us see what is a callback function....
Read more >How to pass a Variable or Argument to a callback function in ...
The assignment is simple. Search user with the name given, update the address of the user and print the user details after the...
Read more >Callback Function Javascript
A JavaScript Callback is a function passed as an argument to another function. In the above example, we passed in as an argument...
Read more >JavaScript Callback Functions – What are Callbacks in JS and ...
In JavaScript, the way to create a callback function is to pass it as a parameter to another function, and then to call...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The following worked for me HTML:
Script:
Your solution is print “undefined”
So it doesn’t work !!!