jasemilly Posted July 9, 2012 Share Posted July 9, 2012 Hi I have created my first php script with functions and using ajax the function will be called. I get a message saying error in function {main}. <?php $FuncName=$_GET["FuncName"]; if ($FuncName = "InternetAccessTest") { echo PingTest; } function PingTest() { $host = 'www.karoo.co.uk'; $up = ping($host); return ($up ? '<div class="ribbon green">OK</div>':'<div class="ribbon red">!!!</div>'); } ?> What am I doing wrong?? thanks jasemilly Quote Link to comment https://forums.phpfreaks.com/topic/265433-new-to-ajax-and-php/ Share on other sites More sharing options...
redarrow Posted July 9, 2012 Share Posted July 9, 2012 we need to see the ajax aswell but it in php forum we don't mind i think? Quote Link to comment https://forums.phpfreaks.com/topic/265433-new-to-ajax-and-php/#findComment-1360297 Share on other sites More sharing options...
jasemilly Posted July 9, 2012 Author Share Posted July 9, 2012 Hi I use the built in jquery method to call for ajax setInterval($(".ribbon-wrapper").load("php/NetWorkToolBox.php","InternetAccessTest"),0); THis is the actual error Undefined index: FuncName in C:\xampp\htdocs\wallboard\php\NetWorkToolBox.php on line 3 thanks Quote Link to comment https://forums.phpfreaks.com/topic/265433-new-to-ajax-and-php/#findComment-1360315 Share on other sites More sharing options...
jcbones Posted July 9, 2012 Share Posted July 9, 2012 2 problems. 1. There is no query string ($_GET) in your URL to NetWorkToolBox.php. 2. In the top script, you should call the function with echo PingTest(); Edit: I think you can fix #1 by making it. setInterval($(".ribbon-wrapper").load("php/NetWorkToolBox.php","FuncName=InternetAccessTest"),0); Quote Link to comment https://forums.phpfreaks.com/topic/265433-new-to-ajax-and-php/#findComment-1360380 Share on other sites More sharing options...
jasemilly Posted July 10, 2012 Author Share Posted July 10, 2012 thanks that worked!! Quote Link to comment https://forums.phpfreaks.com/topic/265433-new-to-ajax-and-php/#findComment-1360631 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.