i am trying to process a jsp page via ajax request and insert it into the main page like this.
$.get(‘link to page’, function(data) {
$(‘#formContainer’).html(data);
});
in my jsp page that i am getting back from the server there is javascript code that i want to include with the html and will handle the form events (i have many forms and each one has a different functionality)
it seems that the javascript code isn’t added to the page with the html code.
Any way to do to what i want?
thanks.
$.get()will strip outscripttags ( see docs);You can use
load()which will honor script. You need to place script after the html it affects sincedocument.readyhas already occurred in the main page.API Reference: http://api.jquery.com/load/
Docs explain script execution