Jump to content

Recommended Posts

Hi,

         This is my first post in this forum and am a PHP beginner. I have written a script in php and need to use echo to see the values of variables etc. However I dont get the output on the screen while using echo . I am using Xampp server with Apache.

The startup.html file code is

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
        <title>Test Page</title>
   
        <script>
             $.ajax(
                    {
                        url: "http://localhost:8081/test.php",
                        type: 'POST',
                        dataType: 'text',
                        data: {latitude: '7.15588546', longitude: '81.5659984458'},
                        success: function (response)
                        {
                            alert(response);
                        },
                        
                        error: function (response)
                        {
                            alert(response);
                        }
                        
                    });
      
        </script>

        </head>
    <body>
    <p>hello</p>
    </body>
</html>

 

and the test.php code is

<?php

$lat = $_REQUEST['latitude'];
$lon = $_REQUEST['longitude'];

echo 'latitude- '.$lat . ', longitude- ' . $lon;
?>

Please help

regards

 

Sanjish

Make sure you have error reporting on -
 

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

If that isn't working then your local server isn't set up right. 

To test if you local server is working properly create a php info file. 

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

 

Edited by Strider64

Whenever i use echo in the php file the ajax call returns a Parserror. If i remove echo then the ajax call is a success. Hope that helps . I am at my wits end really . I tried calling  phpinfo() . But it shows nothing. What do i do to set the Xampp server right. ?

  • 2 weeks later...
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.