Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将php全局变量传递到ajax.success()中_Javascript_Ajax - Fatal编程技术网

Javascript 将php全局变量传递到ajax.success()中

Javascript 将php全局变量传递到ajax.success()中,javascript,ajax,Javascript,Ajax,我有一些ajax代码: $.ajax({ url: "/ajax/createOrder.php", type: "POST", cache: false, data: { "nameSelf": nameSelf, "phoneSelf": phoneSelf, "email": email, "delivery": delivery }, dataType: "html", success: function(data) {

我有一些ajax代码:

$.ajax({
  url: "/ajax/createOrder.php",
  type: "POST",
  cache: false,
  data: {
    "nameSelf": nameSelf,
    "phoneSelf": phoneSelf,
    "email": email,
    "delivery": delivery
  },
  dataType: "html",
  success: function(data) {
    -- -- -- -- -- -- > $("#orderConfirmationDescription").html("<?php $userOrderId ?>");
  }
});
$.ajax({
url:“/ajax/createOrder.php”,
类型:“POST”,
cache:false,
数据:{
“名称自我”:名称自我,
“phoneSelf”:phoneSelf,
“电子邮件”:电子邮件,
“交付”:交付
},
数据类型:“html”,
成功:功能(数据){
---->$(“#订单确认说明”).html(“”);
}
});

如何将全局
$userOrderId
传递到元素中?

在PHP中使用
echo
,并删除双引号

$("#orderConfirmationDescription").html(<?php echo $userOrderId; ?>);
$(“#订单确认说明”).html();