Jump to content

new to ajax and php


jasemilly

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/265433-new-to-ajax-and-php/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/265433-new-to-ajax-and-php/#findComment-1360315
Share on other sites

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);

 

Link to comment
https://forums.phpfreaks.com/topic/265433-new-to-ajax-and-php/#findComment-1360380
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.