0

I called a PHP script with jQuery but it doesn't return any response if i instantiate a class before echo-ing the response. Meaning that it works if i instantiate the object after.

javascript code :

$.post('libraries/test.php', {action: 'duplicateForm', service: service_name}, function(response)
{
    console.log(response);
});

php script:

$response = '1';
$f = new usvn_form_insert();
$response = '2';
echo $response;

I don't use the $_POST variables in this test. With this, the response is empty but if I put the echo before $f = new usvn_form_insert(); it prints 1

5
  • 2
    What is your error reporting set to in php.ini? It is likely you are getting a fatal error or something from that class that is not outputted to the browser.
    – Jage
    May 4, 2011 at 16:03
  • 1
    Do you have access to the server error logs? There should be a message there. One of several things is happening : the usvn_form_insert object isn't available due to a missing include, the constructor expects args, or the constructor is failing for reasons we can only guess at without an error message.
    – Phil Lello
    May 4, 2011 at 16:15
  • Obviously there is some problem when instantiating of the object. Try looking inside its constructor, checking whether Your usvn_form_insert class exists (when on UNIX system, letter cases must also match), etc... Providing us the error report would be appreciated...
    – shadyyx
    May 4, 2011 at 16:23
  • I love when people call them 'easy ones' but they are on this site asking anyway...
    – Dutchie432
    May 4, 2011 at 16:31
  • my reporting error is set to E_ALL. And there is no error, the class exists and the include is ok, the constructor doesn't expect args. It does the same thing if i write a require_once instead of an instantiation
    – Peekyou
    May 4, 2011 at 17:39

1 Answer 1

1

Put error_reporting(E_ALL) at the top of your php script and see if it returning any error back to the browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.