Getting PHP Content into Javascript Variable

Miscellaneous Forums/General Discussion/Getting PHP Content into Javascript Variable

Hi all,

Well another day another problem. This time, I am trying to get the content of a PHP page (one that counts the total number of records in a table for a paging function) into a javascript variable.

So basically I want to go something like


var totalPages = GetContent("/recordCount.php?tablename=whatever");


Ive got jQuery and Prototype libraries installed in this project. There is also something called TinyMCE but i think thats an editing control.

Anyone done this?

A

var woop = $.ajax({
	type: "GET",
	url: 'woop.php?dog=cat&up=down',
	async: false
	}).responseText;


is what I use with Jquery

Is this page with the Javascript also a PHP page? You can do this

<?php $jsvar = Getinfo(); ?>
<script type="Javascript">
var totalPages = <? echo $jsvar; ?> ;
</script>


Raz, you are a legend mate. Worked a treat! Thanks

Sorry Flav, didnt see your post there (didnt refresh browser). Another handy tip which i may have to use later on, but for now Raz has nailed this particular problem.

Cheers again
Andy