PDA

View Full Version : javascript in ajax



XAKERA
03-11-2008, 07:55 AM
I use ajax tab content. and when i add <script src=url></script> this javascript doesn't work. How make it to work javascript in ajax.
Thanks

rangana
03-11-2008, 08:01 AM
Have you tried using <script type="text/javascript" src=url></script> instead? ;)

XAKERA
03-11-2008, 09:02 AM
yes but it doesn't work. Ajax can;t load javascript

boogyman
03-11-2008, 01:10 PM
AJAX IS Javascript

it stands for Asynchronous Javascript And XML

http://en.wikipedia.org/wiki/AJAX

if you cant get your script to load properly then check that your path is correct, and use some debugging methods like printing out something randomly.

XAKERA
03-11-2008, 03:52 PM
Boogyman thanks but i have firebog. All works great i have ajax spliter and it splits with ||javascript|| but i want add html counter and in there is <script src=counter.php></script> and it doesn't load in my site. How can i make it for work. My site is http://111.ge

boogyman
03-11-2008, 05:56 PM
that is the incorrect format of using a php file included with javascript

Firebug is an add-on that enables you to check different portions of the site. AJAX is simply Javascript presented in a way that allows for communication with a script on the server. This is called "remote scripting". The term AJAX is just a word to describe what is happening, and remote scripting has been around for a while... That is the definition of AJAX.


i want add html counter and in there is <script src=counter.php></script> and it doesn't load in my site
I am going to assume by what you mean by that is you would like to use the server-side "hit" counter at that address.

You have a couple of things you need to fix with your code. First is that you need to add the type attribute as rangana described.. this tells the browser that the "text" within is actually computer code and to use the client-side javascript language to interpret and process the code.
The second bit of info is that it is good coding practice to encapsulate your attributes in quotes, as seen below


<script type="text/javascript" src="/path/to/script.js"></script>


now to actually use AJAX to grab the hit counter information you need to read about how to interact with the server using Javascript... aka AJAX.

for starters, check out the tutorial here done by tech_support http://dynamicdrive.com/forums/showthread.php?t=19247

codeexploiter
03-12-2008, 03:14 AM
If you want to include a script element why don't you use the DOM based method i.e adding a script element in to the head element of your page.