如何用javascript初始化php变量?
您好,我向我的客户发送的电子邮件如下:如何用javascript初始化php变量?,javascript,php,variables,google-schemas,Javascript,Php,Variables,Google Schemas,您好,我向我的客户发送的电子邮件如下: $body='我的电子邮件内容' 我需要在$body变量中添加来自google api的脚本: <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "LodgingReservation", "reservationNumber": "abc456", "reservationStatus": "http://schema
$body='我的电子邮件内容'代码>
我需要在$body变量中添加来自google api的脚本:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "LodgingReservation",
"reservationNumber": "abc456",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "John Smith"
},
"reservationFor": {
"@type": "LodgingBusiness",
"name": "Hilton San Francisco Union Square",
"address": {
"@type": "PostalAddress",
"streetAddress": "333 O'Farrell St",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"postalCode": "94102",
"addressCountry": "US"
},
"telephone": "415-771-1400"
},
"checkinDate": "2017-04-11T16:00:00-08:00",
"checkoutDate": "2017-04-13T11:00:00-08:00"
}
</script>
{
“@context”:”http://schema.org",
“@type”:“住宿预订”,
“reservationNumber”:“abc456”,
“reservationStatus”:http://schema.org/Confirmed",
“姓名下”:{
“@type”:“Person”,
“姓名”:“约翰·史密斯”
},
“预订”:{
“@type”:“住宿业务”,
“姓名”:“旧金山联合广场希尔顿酒店”,
“地址”:{
“@type”:“PostalAddress”,
“街道地址”:“O'Farrell街333号”,
“地址地点”:“旧金山”,
“地址区域”:“CA”,
“postalCode”:“94102”,
“地址国家”:“美国”
},
“电话”:“415-771-1400”
},
“检查日期”:“2017-04-11T16:00:00-08:00”,
“签出日期”:“2017-04-13T11:00:00-08:00”
}
我该怎么做?有什么想法吗?
我不能将“改为”。你的问题不清楚,无论如何,我认为这就是你想要的。
您可以使用Ajax,使用jqueryajax$.Ajax({});
用于在网站中实现跨浏览器ajax支持。使用ajax将该数组发送到实现邮件功能的php文件。只需使用$\u GET
或$\u POST
获取数据。然后将数据附加到邮件正文中
请参阅底层链接以阅读jQueryAjax文档。
如果我理解了这个问题,这应该是你想要的:
$script=