Link to home
Start Free TrialLog in
Avatar of frosty1
frosty1

asked on

How to add <script /> refs in ajax call

I'm noticing that when i look at my html code from fire fox that if i make ajax call my <script tags /> are removed. Is this standard precedure. How do you then do client side validation.

ie Page1 makes an ajax call and gets the content of Page2 which contains a form.

I'm noticing that Page2 is having its <script /> tags remove. Kill my validation.
Avatar of abel
abel
Flag of Netherlands image

No, script tags are not removed by firefox. Your code or transformation might be doing that. It is a fact, however, that the code inside script tags is generally not executed (and having script code in an ajax response is generally considered a bad practice, but that's a different story).

There are several libraries that can help you with this issue. One is Prototype.js, which has methods to execute the returned javascript automatically, and another is jquery, which, iirc, has about the same possibilities.

-- Abel --
Avatar of frosty1
frosty1

ASKER

thanks, that good info.

Actually i'm using prototype

Here is my function. When form.aspx is render it is minus the <script  /> tags. I need this to validate the form on form.aspx

function openOverlay (lat, lng, zoom) {
      
      map.closeInfoWindow();
      new Effect.Appear('curtain', { from: 0.0, to: 0.70, duration: 0.20 });
      new Effect.Appear('display', { from: 0.0, to: 1.0, duration: 0.20, afterFinish: function () {

      new Ajax.Updater('display', '/maps/map1/flagform.aspx?lat=' + lat + '&lng=' + lng + '&zoom=' + zoom, { method: 'get' });
      } });
}
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of frosty1

ASKER

wow , great response.

So as abel saids, you need to part thru evalscript = true.

also, include the script tags in the parent, in my case the validation.js needed to be in the page that called form.

> wow , great response.

thx for the compliment. I remember that I was stumbling upon the same issue, about five years ago, and it took me ages to fix it. Then came prototype and the likes of them, making life much easier.

tx for the points,
-- Abel --