Question: I currently need to use a similar piece of PHP code. Modifying this code is not an option.

```
<?
session_start();

include '../connection.inc';

$conn = new Connection();

echo "ID:" . $conn->generateID();
echo "\n";
?>

```

In connection.inc a connection to a database can be made by creating a new Connection(). From there, the database can generate a unique 16-character ID (conn->generateID).
Is there a way to retrieve to execute this PHP-file from javascript and extract the 16-character ID from the PHP-echo in javascript?

Answer: 
There's an alternative to the AJAX call, though it's a little...unusual. `Output Buffering`.

A little example:

```
<?php
    ob_start();  //This will stop all echoed output from being sent immediately.
    include("Whereveryourcodeis.php");
    ob_end_clean();  //Discards what has been stored and stops buffering.
?>

```

After this fragment, you can use `$conn->generateID` wherever on your page you want, without having written a single line of JavaScript.

I hope this helps a little.
1. Create a JavaScript file that makes an AJAX query to a wrapper PHP file, which calls connection.inc
2. Within JavaScript, call the AJAX query and parse the response, which will give you the ID

Finally, you should probably use HTTPS for this.