0

HTML : My table contains

id    name   action
1     abc    start stop
2     xyz    start stop

when i click on start then the ajax call goes to .php file. The PHP code is for process start. I will start the process with

system("java name ".$port." ".$file_path." ".$ip." 2>&1 &");
echo "Data to test";

The line after system will not get executed and ajax didn't get any success value.

If i remove the system() then the ajax alert(data) gives me php echo statement: "Data to test"

here after the system call the ajax not execute any statement.

James Z
  • 12,209
  • 10
  • 24
  • 44
Ashu
  • 1,320
  • 2
  • 10
  • 24
  • Have you checked your console for error messages? Have you checked in the network tab if the response actually have the status 200 OK and what it actually contains? Have you checked your error logs to see if you get any errors? Please let us know what debugging steps you've taken. – M. Eriksson Jun 30 '17 at 10:45
  • is anything showing up in the php error log? seems like whatever is happening when you call system() is causing issues – Dan Hastings Jun 30 '17 at 10:45
  • no any error in console – Ashu Jun 30 '17 at 10:48
  • Have you checked all the other suggested debugging steps? – M. Eriksson Jun 30 '17 at 10:48
  • Concatenate variable $port properly. Replace this line with system("java name ".$port." ".$file_path." ".$ip." 2>&1 &"); – Suni Jun 30 '17 at 10:50
  • @MagnusEriksson yes... I think it is bcz of system() it create one java process. is there any other way to create process other than system.. I check console, network there is no any error – Ashu Jun 30 '17 at 10:51
  • You can not have checked the error log since @Suni just pointed out a typo that would have given you a parse error. If you _did_ check the error log and it was empty, then you should turn on error reporting. Here's a good post on how to turn it on and how to display errors: https://stackoverflow.com/questions/5438060/showing-all-errors-and-warnings – M. Eriksson Jun 30 '17 at 10:53
  • Possible duplicate of [PHP's white screen of death](https://stackoverflow.com/questions/1475297/phps-white-screen-of-death) (that is essentially the problem you are dealing with there; you just got yourself mislead by the fact that the request is made via AJAX, but that does not mean AJAX has anything to do with the error itself.) – CBroe Jun 30 '17 at 10:55
  • before mentioning -ve 1st check my quetion... & give me reason why ? – Ashu Jun 30 '17 at 10:56
  • We have given you a reason why. Please read our comments, try our suggestions and come back with the results. If you don't read/try what we suggest, we're kind of stuck, no? (and I have no clue what -ve refers to). Since you have a parse error, your `system()`-call won't even be called. – M. Eriksson Jun 30 '17 at 11:01
  • no i tried all things... so the suggested link & also check the apache error log , there is no error..but my console wont show me any error... & if the problem in the system() then why process get created...?? – Ashu Jun 30 '17 at 11:03
  • @MagnusEriksson but the process get created & also the process id is created & $port id is the typing error from my side.. sorry for that... – Ashu Jun 30 '17 at 11:06
  • Add the 2nd parameter to get the return status of the executed command and debug if you found any issue. Refer : [System()](http://php.net/manual/en/function.system.php) – Suni Jun 30 '17 at 11:26
  • 1
    Does the process you're starting actually end or does it keep running? From the manual about [`system()`](http://php.net/system): _"If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends."_ – M. Eriksson Jun 30 '17 at 11:26
  • It keeps running... – Ashu Jun 30 '17 at 11:41

0 Answers0