ajax - how to send value of a php variable in java script -
i getting post data docusign .to catch post data using file contents. after parsing want send backend ajax. how send value of php variable in java script. php code
<?php //$postedxml = file_get_contents('php://input'); //$xml = simplexml_load_string($postedxml); //$xml[0]->envelopestatus->status; $foo = "completed"; echo " <script language='javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script> <script> jquery.ajax({type : 'post', url : 'xxxx.xx.xxxx', data:{content:'<?php print $foo; ?>'}, success : function(data,textstatus, jqxhr) { alert('you have succesfully sent agreement to'); }, error : function(errjqxhr, errtextstatus, errthrown) { } }); </script>"
if send data getting this. want send hello. how that.
you're in middle of large echo
statement when this:
echo "... ... ... <?php print $foo; ?> ... ... ..."
you don't need (or want) <?php ?>
tags in echo
statement. emit variable directly. it's double-quoted string, variables expand:
echo "... ... ... $foo ... ... ..."
or can explicitly concatenate:
echo "... ... ..." . $foo . "... ... ..."
or, think large echo
statements difficult follow. go original intent , separate markup php:
?> ... ... ... <?php print $foo; ?> ... ... ... <?php
putting inside of echo
statement unnecessarily wraps client-side code in server-side code. creates unnecessary overhead, limits can quoting, , makes client-side code more difficult read.
Comments
Post a Comment