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.
我用jQuery调用了一个PHP脚本,但是如果我在回显响应之前实例化一个类,它就不会返回任何响应。这意味着如果我实例化之后的对象,它的工作原理。
javascript code :
javascript代码:
$.post('libraries/test.php', {action: 'duplicateForm', service: service_name}, function(response)
{
console.log(response);
});
php script:
php脚本:
$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
我在这个测试中不使用$ _POST变量。有了这个,响应是空的,但如果我把回声放在$ f = new usvn_form_insert()之前;它打印1
1 个解决方案
#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.
将error_reporting(E_ALL)放在php脚本的顶部,看看它是否将任何错误返回给浏览器。
#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.
将error_reporting(E_ALL)放在php脚本的顶部,看看它是否将任何错误返回给浏览器。