How to execute javascripting inside of ajax response ?

Problem : I have written one html+scripting response from ajax code. sometime problem is that in response we write <script> tags. and we think that these script tags are executed when we use following code

when we get such response we thing that alert will be excuted. but officially its not executed. script element will be added in all collection node. considering as html entities. and not as script entities. so for executing script as script we have to do things are below.

Last time I tried this option but it did not worked for me. I thought it was basically problem with IE only. as firefox working properly. then again I google many people suggested that scripting should be appended on head elements. but still that also doesn’t work.

After lots of attempts I found when response is send by server then first data (or first line of data) need to be html then only above function works for it. To understand it properly let me explain you in short.