Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.