开发者

PHP instantiation breaks the script with AJAX call

开发者 https://www.devze.com 2023-03-03 11:46 出处:网络
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.

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 u开发者_开发技巧svn_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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消