Page 1 of 1

Newbie jquery question [SOLVED]

Posted: Mon Jul 26, 2010 3:39 pm
by nickeh
I hope I'm posting in the right place. I have problems getting a div id updated by jquery. In a simple html page I get the div updated but when I insert it to my CMSMS template there is nothing. I'm sure that there is a simple solution for this but I tried to google for a couple of days and I havn't figured out what I'm doing wrong. My template is a custom 960.gs based and works perfectly otherwise. My code looks like this (only part of it, and this is between tags)

Code: Select all

{literal}
<__script__ src="http://code.jquery.com/jquery-latest.js"></__script>
<__script__>
 $(document).ready(function() {
         $("#dbdata").load("http://server/script.php");
   var refreshId = setInterval(function() {
          $("#dbdata").load('http://server/script.php?randval='+ Math.random());  }, 10000);
});
</__script>
{/literal}
and lower on the page I have this

Code: Select all

<div id="dbdata">test</div>
The test text blinks for a ms but then its gone. I can see in the apache log that calls are made to the php script (that just has a echo date.....) and it works if I calls it from a basic html page. The div is inside of lots of other divs if that could be the problem...

Any ideas?

Thanks in advance!

Re: Newbie jquery question

Posted: Mon Jul 26, 2010 3:55 pm
by Dr.CSS
Try moving the {literal} tags inside the       call...

Re: Newbie jquery question

Posted: Mon Jul 26, 2010 4:21 pm
by nickeh
Thanks for a fast response, but the result is the same...

Re: Newbie jquery question

Posted: Mon Jul 26, 2010 6:17 pm
by JeremyBASS
two things.. use firebug in firefox to watch the net to make sure you are truing doing the load and  two.. any errors?  Cheers -Jeremy

Re: Newbie jquery question

Posted: Mon Jul 26, 2010 6:45 pm
by nickeh
Yep, the loading is done and no errors (200 OK). BUT I discovered that the response is empty, so this explains alot (the php script is during testing on another server could that be a problem?). I'll keep you updated on what I find.

BTW is it possible to call a User Defined Tag instead of using an URL in load? If possible how do I call it?

THANKS Jeremy!!!

Re: Newbie jquery question

Posted: Mon Jul 26, 2010 7:09 pm
by JeremyBASS
nickeh wrote: (the php script is during testing on another server could that be a problem?).
I'd bet it's the logic in the php script..
nickeh wrote: BTW is it possible to call a User Defined Tag instead of using an URL in load? If possible how do I call it?
Atm no but IIRC it's planed to b able to.. but here is a trick that may work for you.. put the udt at the top of the template.. and end the udt with exit after the return... now you can call any page with a param like ?foo=bar and with the right logic testing for foo in the udt then if foo is not there the udt quite does nothing.. hope that helps.. but there are 50 ways to do this and it's always good to test and try so see what fits you.. Cheers -Jeremy

Re: Newbie jquery question

Posted: Mon Jul 26, 2010 7:21 pm
by nickeh
I uploaded the script to the same server and now its working perfectly. Thanks Jeremy you saved my day!!!