WebFaction
Community site: login faq

I'm seeing the resource is located through Firebug, but the script doesn't seem to be executing. Something tells me it has to do with the Apache configuration or the word "static" in the App type. Does anyone know what steps I might be able to take to enable an application to run a PHP script via an AJAX/XHR request?

I'm currently using the PHP glob() function to grab a directory of images. It's possible glob() is not supported on this version of PHP - not exactly sure how to check for specific functions though. If I echo out at the top of the file, and go to my scripts directory and run the script, I do see the echo, but it doesn't appear to ever get to the point where it echos "File: " . $files:

EDIT: It appears that the script just refuses to see my GET variables. The logic block if ($HTTP_GET_VARS['send_stream']) is always evaluating to false even if I put the GET vars into the AJAX call or directly into the browsers

if ($HTTP_GET_VARS['send_stream']) {
    $payloads = array();

    # $i = 0;
    $files = glob("../img/*.svg");
    echo "Files:" . $files;

    foreach($files as $svg){

        $handle = fopen($svg , "r");
        $data = fread($handle, filesize($svg));

        echo $i . ': ' . $handle;

        $payloads[] = mxhr_assemble_xml_payload($data, $svg);
        fclose($handle);

        # $i++;

    }

    #
    # Send off the multipart stream
    #

    mxhr_stream($payloads);
    exit;
}

asked 12 Jan '13, 16:31

netpoetica
336
accept rate: 0%

edited 13 Jan '13, 01:44


PHP is a server side language, JavaScript(when used for AJAX and not something like node.js) is a client side language. So it can not be loaded externally with JavaScript, you would have to use PHP to load it. Server side is processed before the DOM/client side. Try debugging the script on the server itself by exeucting php on the file,

php index.php

If you mean to simply trigger the PHP file via a request, than that is like any normal GET or POST HTTP request.

permanent link

answered 12 Jan '13, 17:10

johns
5.4k312
accept rate: 23%

edited 12 Jan '13, 17:20

Hey Johns thanks for your response! AJAX is Asynchronous JavaScript and XML, but over time, the X in AJAX has come to represent various forms of web technology like JSON and server-side scripts like PHP. Over the past few years, people have been using AJAX requests to update a webpage similarly to how a program in general might use a thread.

The problem I am trying to adress is that my AJAX call, which runs a PHP script, is running perfectly fine on my localhost but failing on webfaction - so its most likely a problem of webfaction out-of-the-box hosting of "php apps".

(13 Jan '13, 01:33) netpoetica

In this situation, I have realized that $HTTP_GET_VARS has been deprecated and I should use $_GET instead :) very simple. This code came from my experimentation with MXHR via Digg developers, so I used code that can't be very old but must be old enough to suffer this result. Ultimately, it had nothing to do with webfaction and everything to do with the fact that I have been using Nodejs so much I've lost touch with PHP

permanent link

answered 13 Jan '13, 01:50

netpoetica
336
accept rate: 0%

Glad to hear you found the problem.

(13 Jan '13, 02:37) johns
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×31

question asked: 12 Jan '13, 16:31

question was seen: 3,374 times

last updated: 13 Jan '13, 02:37

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM