Ajax page loading and Scripts contained in these pages
Hi everyone.
I have a script that automatically convert each forms to Ajax forms. This script do the form submission with the "serialize()" function and then extract a part of the response and append it to the page.
This script works fine but many of our pages contains scripts in page header so I want to also load theses scripts to the page but I don't know how to do that. I have tried to obtains the scripts with "$response.find('script').text()" but the result is 'null'.
Thanks
- $('form[action=\''+window.location.pathname+'\']').each(function(){
- var $form = $(this);
- $form.submit(function(event){
- $.save();
- event.preventDefault();
- $.ajax({
- type: $form.attr('method'),
- url: $form.attr('action'),
- data: $form.serialize(),
- dataType: 'html',
- success: function(resp) {
- var $response = $(resp);
- $("#content").empty();
- $("#content").append($($response.find("#content").html()));
- $("#content").trigger('change');
-
- // Load and eval the scripts contained into $response
- initPage();
- $.unblockUI();
- }
- });
- return false;
- });
- });