I have a page which is divided in to many tabs , with each tab pulling data from another pages through ajax.
After the ajax call, i use a .html ( data ) where data is the html of called page to insert it in to the tab. My question is , if the called page has javascript functions , will those be executed and resultant data is sent or just the html page is s开发者_Python百科ent?
Kindly help.
Thanks.
Yes, as long as you are specifying:
dataType: "html",
inside your ajax call.
From http://api.jquery.com/jQuery.ajax/ :
If html is specified, any embedded JavaScript inside the retrieved data is executed before the HTML is returned as a string. Similarly, script will execute the JavaScript that is pulled back from the server, then return nothing.
What is returned by the server is different from what is displayed on the page. The file you receive back isn't processed before Jquery touches it. However, as soon as Jquery receives it, the scripts are subsequently executed. So no, the scripts are not run prior to Jquery's receipt of the contents.
精彩评论