ajax - Why doesn't this simple PHP return a response? -




this first php program i've written. ajax requests alright , i'm getting status 200 ok not getting response.

<?php  class employee{     private $fn;     private $ln;     private $dpt;     private $id; }  function newemployee(){     $employee = new employee();     $fn = $_post['firstname'];     $ln = $_post['lastname'];     $dpt = $_post['department'];     $id = sprintf('%08d', $globals['$id']);     $globals['$id'] = $globals['$id'] + 1;      echo "first name: $employee\nlast name: $ln\ndepartment: $dpt\nid: $id";      $employee -> fn = $_post['firstname'];     $employee -> ln = $_post['lastname'];     $employee -> dpt = $_post['department'];      $globals['$employeearray'][]= $employee;      $globals['$numofemployees'] = $globals['$numofemployees'] + 1;     $numemployees = $globals['$numofemployees'];      echo "first name: $employee\nlast name: $ln\ndepartment: $dpt\nid: $id\nnumber of employees: $numemployees";   }  if(isset($_post['submit'])) {    newemployee(); }  $employeearray = array(); $id = 0; $numofemployees = 0;  ?> 

literally first php program i'm sure it's dumb. enter image description here enter image description here

your code breaks because of line:

 echo "first name: $employee\nlast name: $ln\ndepartment: $dpt\nid: $id"; 

what's happening is, you're trying output $employee = new employee(); string when it's object. php breaks here , not want continue going through rest of code.

maybe wanted so?

 echo "first name: $fn\nlast name: $ln\ndepartment: $dpt\nid: $id";       

you'll want replace other call of $employee in second echo @ bottom of function.

as macbooc correctly pointed out, you're not sending $_post['submit'] form, maybe change so?

if(isset($_post['submit']))      

->

if(isset($_post)) 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -