this is my page Test1.asp
Adding a element into a document via
innerHTML
doesn't(*) execute its contents as a script.
You're also trying to insert the entire HTML document, including If you need to return both HTML and some script to execute, better to return a JSON object, eg.: then parse the JSON object, set the (*: Well, doesn't generally. Exactly when a ,
and
inside a
{
"html": "",
"js": "document.getElementById(\"Mathew\").innerHTML='ajax is working';"
}
innerHTML
to obj.html
and eval
the js
. (Though it's generally questionable to be returning and executing arbitrary, scripts, there can sometimes be a use for it.) element's contents get executed is browser-dependent. For example Firefox executes script when you append/insert a DOM HTMLScriptElement or ancestor into an element that is part of the document, whereas IE executes it when you insert the element into any parent for the first time, whether inside the document or not. In general, avoid inserting JavaScript-in-HTML content into HTML.)