SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Enthusiast elena_sev's Avatar
    Join Date
    Apr 2003
    Sofia, Bulgaria
    0 Post(s)
    0 Thread(s)

    Question transffering date between two servers

    Hello everyone,

    I'll try to explain what I am trying to do again because its not clear I guess

    I have a javascript which is called on every requested page. This script checks for a cookie if the cookie exists the script calls a php script on another server. But if the cookie is not set then it should make a request to the other server. The other server should get an unique ID from a database and then return the ID to the javascript that requested it. The last thing to do is to set a cookie with this ID.

    I searched the internet and come across this:

    the javascript call a php file on the second server :

    // Get base url
    url = document.location.href;
    xend = url.lastIndexOf("/") + 1;
    var base_url = url.substring(0, xend);
    function ajax_do (url) {
            // Does URL begin with http?
            if (url.substring(0, 4) != 'http') {
                    url = base_url + url;
            // Create new JS element
            var jsel = document.createElement('SCRIPT');
            jsel.type = 'text/javascript';
            jsel.src = url;
            // Append JS element (therefore executing the 'AJAX' call)
            document.body.appendChild (jsel);
    and a php.file that get an ID from a database and assign it to a javascript variable:

    var uid=<? echo $uniqueID; ?>
    when I execute the javascript code it then executes the php code but the variable is not set

    Has anybody any idea what i miss and what is not ok with this
    Is there another way to accomplish this
    Please any suggestions
    Thank you
    Last edited by elena_sev; Jun 5, 2007 at 06:39. Reason: make clear my question


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts