sent javascript variable to php and it prints out "Array" -


i sent javascript variable containing innerhtml "basic" php ajax , sent email variable , returned "array" opposed "basic". confused.

html:

<label class="plan-name">plan name: <b id="somii-plan">basic</b></label> 

javascript/ajax:

var somiiplan = document.getelementbyid('somii-plan').innerhtml; var request = $.ajax({      type: "post",      url: "somii-pay.php",      datatype: "json",      data: {         "somiiplan" : somiiplan,         "email" : email,      }   }); 

php:

$somiiplan = ['somiiplan']; $email = $_post['email'];  $email_to = "******"; $email_subject = "somii test charge"; $email_message = "your plan is: " . $somiiplan; $headers = 'from: '.$email."\r\n". 'reply-to: '.$email_to."\r\n" . 'x-mailer: php/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); 

your js looks fine datatype used set type of response ,not request.

your php has problem

$somiiplan = ['somiiplan']; 

will be

$somiiplan = $_post['somiiplan']; 

here creating array on $somiiplan , not getting post param why returning array.

also note not sending response , not handling response in js,so not required set datatype. , if sending response make sure send on json encoded form.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -