简体   繁体   English

PHP变量通过Ajax传递

[英]PHP variable pass through Ajax

I have PulsePro as CMS used. 我使用PulsePro作为CMS。 The template is on PHP, but the include parts are in HTML. 该模板在PHP上,但是包含部分在HTML中。 The php mailer contains an Ajax Script, which I have implemented in the layout.php file. php邮件程序包含一个Ajax脚本,该脚本已在layout.php文件中实现。 I have some different forms with different receiver email addys. 我有不同的收件人电子邮件地址表格。 Now, I want to define a variable for following string. 现在,我想为后面的字符串定义一个变量。 This variable it will taken from the different include parts, eg 该变量将从不同的包含部分中获取,例如

Here the link in the include files. 此处包含文件中的链接。

<?php $variable ="ajax1.php"; ?> 

This is the ajax code in the layout.php file: 这是layout.php文件中的ajax代码:

ajaxSubmit = function(){
            var frmData = $("#ifgForm").serialize();
            $.ajax({
                **url: "/includes/ajax.php", This is the original part, but here should be the variable
                data:     frmData,
                type:     "POST",
                dataType: "json",
                success: function(response){
                    $("#f1_upload_process").hide();
                    $(".event-submit-btn").show();

Thanks for your support. 谢谢你的支持。

You can output the string inside ifgForm like this 您可以像这样在ifgForm中输出字符串

<form id="ifgForm">
   <!-- [....] -->
   <input type="hidden" value="<?=$variable?>" name="variable" id="variable"> 
   <!-- [....] -->    
</form>

So u can find in the new variable field with other form fields data 因此,您可以在新的变量字段中找到其他表单字段数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM