/    Sign up×
Community /Pin to ProfileBookmark

Javascript not working inside ajax pages

Hi,

I have an ajax tab script.

I want to call a simple javascript alert within the ajax pages. Each page will alert the text.

[code=php]<script type=”text/javascript”>
<!–
alert(“test”);
//–>
</script>[/code]

But it doesn’t work when using ajax. It works when the script is called directly though.

Anybody know the issue?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Mar 08.2009 — JavaScript is not evaluated when it is placed in a page with innerHTML.

You need to rip it out and eval() it yourself. If you use a library such as JQuery or Protoype.js, they have the feature built into their Ajax calls.

Eric
Copy linkTweet thisAlerts:
@sc_kingauthorMar 08.2009 — Do you have any examples of how to use jquery with for ajax tab pages?

Thanks again for your reply.
Copy linkTweet thisAlerts:
@sc_kingauthorMar 08.2009 — Also, what do u mean by ripping it out and eval() it?
Copy linkTweet thisAlerts:
@sc_kingauthorMar 09.2009 — Anybody have any ideas?
×

Success!

Help @sc_king spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...