Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot call a user defined JS function after return the AJAX content

I am having a problem of calling the user defined JS function after I make the AJAX call. Basically, I created couple radio buttons on the main html page. When the user clicks on one of the radio button, it will trigger the AJAX call and return another html file in the "div" content that I set in the main html page. The other html file contains a user defined JS function (e.g. "updateContent()") which use the onclick event handler to call the function. When I'm running the app, and click on the button. I had seen the firebug was complaining the "updateContent() is not defined" error. The function itself works fine and must be defined properly. Please help me about this! Thanks.

like image 365
R.Spark Avatar asked Apr 01 '26 02:04

R.Spark


1 Answers

The magic Google words here are "JSON-P" and the "On Demand Javascript" pattern. Basically, instead of loading a chunk, you create and load a tag. Then the javascript gets interpreted, your function is defined, the nail is found, the horse is shod and the kingdom is not lost.

like image 160
Charlie Martin Avatar answered Apr 02 '26 20:04

Charlie Martin