Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add a callback to eval(data);?

So when eval(data) is complete, how would you set a callback?

like image 479
Trip Avatar asked Jan 21 '23 08:01

Trip


1 Answers

Eval is not asynchronous, so you don't need a callback. Just put your function call on the next line.

The script you are evalling might do something asynchronous, in which case you would need to parse the JS, find the asynchronous code, and add a callback to that (in string form).

Best to avoid eval in the first place though. It is almost never the right solution to a problem.

like image 162
Quentin Avatar answered Feb 01 '23 15:02

Quentin