Customizing SMF > SMF Coding Discussion

jquery and smf help

(1/1)

Glyph:
Basically i'm trying to use


--- Code: ---<script type="text/javascript" src="/js/jquery-1.8.0.min.js" ></script>
  <script type="text/javascript">
  $(document).ready(function() {
  $("#targe").load("test.php");
  var refreshId = setInterval(function() {
  $("#targe").load("test.php");
  }, 30000);
  });
--- End code ---


to update my test.php script dynamically every 30 seconds into the div "targe"

e.g.


--- Code: ---<div id=targe></div>
--- End code ---

now here is where it gets complicated...

i'm using SMF integration hooking with this so when function template_main()  loads from "test.template.php" its spitting out test.php at the top of the page and ignoring my jquery code.

anybody have some experience with this?

ii can give u a link to the site and code on request - i'de really appreciate any help that can be given ive spent hours trying to figure this out and i sitll cant find a solution.


Sorck:
You'll need to add to $context['html_headers'] in your hook function.


--- Code: ---<?php
function my_hook_function($my_args[, ...])
{
global $context;
$context['html_headers'] .= '<script type="text/javascript" src="/js/jquery-1.8.0.min.js" ></script>
  <script type="text/javascript">
  $(document).ready(function() {
   $("#targe").load("test.php");
  var refreshId = setInterval(function() {
   $("#targe").load("test.php");
  }, 30000);
  });';
}
--- End code ---

That, or something like it, should do the trick. :)

Navigation

[0] Message Index

Go to full version