0

I would like to create a PHP page which accepts an arguement like so:

http://localhost/page.php?topic=Foo

and then pulls data from an SQL Database where topic=Foo but then automatically checks for new data every 10 seconds and refreshes a DIV tag using Ajax. I've tried and nothing works. Any help?

EDIT: here is the code I've used:

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
 ext = <?php $_GET[feedtitle] ?>
 $(document).ready(function() {
     $("#responsecontainer").load("response.php?ext=" + ext);
   var refreshId = setInterval(function() {
         $("#responsecontainer").load('response.php?ext=' + ext);
   }, 9000);
   $.ajaxSetup({ cache: false });
});
</script>
</head>
<body>

<div id="responsecontainer">
</div>
</body>

EDIT: I can do the SQL bit, it's just the getting the arguement to the response.php im having issues with.

EDIT: I have new code, but its still not working:

<html> 
<head> 
<script src="http://code.jquery.com/jquery-latest.js"></script> 
<script> 

function gup( name )
{  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null ) 
   return ""; 
 else    
   return results[1];
}

var feed = gup('f');

$(document).ready(function() { 
$("#responsecontainer").load("response.php?ext=" + feed); 
var refreshId = setInterval(function() { $("#responsecontainer").load('response.php?    ext=' + feed); }, 9000); 
$.ajaxSetup({ cache: false }); 
}); 
</script> 
</head> 
<body> 

<div id="responsecontainer"> 
</div> 
</body> 
Richard Sparrow
  • 101
  • 1
  • 12

1 Answers1

1

So, you need to Get escaped URL parameter , output the jquery $.post function's result data and then you just need to know How to refresh page with jQuery Ajax? and do an AJAX Div Retrieval every 60 seconds?

I hope that helps :)

Community
  • 1
  • 1
Quasdunk
  • 14,944
  • 3
  • 36
  • 45