Newbie jquery question [SOLVED]

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
nickeh
New Member
New Member
Posts: 6
Joined: Mon Jul 26, 2010 3:19 pm

Newbie jquery question [SOLVED]

Post 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!
Last edited by nickeh on Mon Jul 26, 2010 7:22 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Newbie jquery question

Post by Dr.CSS »

Try moving the {literal} tags inside the       call...
nickeh
New Member
New Member
Posts: 6
Joined: Mon Jul 26, 2010 3:19 pm

Re: Newbie jquery question

Post by nickeh »

Thanks for a fast response, but the result is the same...
JeremyBASS

Re: Newbie jquery question

Post 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
nickeh
New Member
New Member
Posts: 6
Joined: Mon Jul 26, 2010 3:19 pm

Re: Newbie jquery question

Post 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!!!
JeremyBASS

Re: Newbie jquery question

Post 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
nickeh
New Member
New Member
Posts: 6
Joined: Mon Jul 26, 2010 3:19 pm

Re: Newbie jquery question

Post by nickeh »

I uploaded the script to the same server and now its working perfectly. Thanks Jeremy you saved my day!!!
Post Reply

Return to “The Lounge”