Php 对模块的Ajax调用不返回任何内容
我的目标是能够使用magento从html页面生成pdf。但是,我仍然无法成功地执行ajax请求 我得到了ajax调用,但它没有返回Specsheetpdf.phtml文件中的内容 我可能做错了,这方面我还不太熟悉 在主题文件夹中的view.phtml文件中,我有一段代码,当单击按钮调用specsheetpdf.phtml文件生成pdf时,该代码使用ajax:Php 对模块的Ajax调用不返回任何内容,php,jquery,ajax,magento,wkhtmltopdf,Php,Jquery,Ajax,Magento,Wkhtmltopdf,我的目标是能够使用magento从html页面生成pdf。但是,我仍然无法成功地执行ajax请求 我得到了ajax调用,但它没有返回Specsheetpdf.phtml文件中的内容 我可能做错了,这方面我还不太熟悉 在主题文件夹中的view.phtml文件中,我有一段代码,当单击按钮调用specsheetpdf.phtml文件生成pdf时,该代码使用ajax: jQuery(document).ready(function() { jQuery( "input#printPDF_RDT"
jQuery(document).ready(function() {
jQuery( "input#printPDF_RDT" ).click(function() {
//get all value
var prod_name = jQuery("#product_name_RDT").text();
var prod_details = jQuery(".box-description .std").html();
var prod_image = jQuery(".product-image #image").attr('src');
//Before we get the options html we need to wrap it around a div to make things easy
jQuery("#product-options-wrapper").wrap("<div id='product_options_RDT'></div>");
//Now get the html in the created div
var prod_options = jQuery("#product_options_RDT").html();
var prod_sku = jQuery("#showsku").text();
// Do AJAX call to makePDF.php
jQuery.ajax({
type: "POST",
url: "<?php echo $this->getUrl('specsheetpdf/ajax/index') ?>",
data: { product_name: prod_name , product_details: prod_details,
product_image: prod_image, options_html : prod_options,
product_sku : prod_sku },
success: function(data) {
jQuery('#results_rdt').html(data);
}
});
});
});
app/code/local/Rdtmodules/Specsheetpdf/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Rdtmodules_Specsheetpdf>
<version>0.1.0</version>
</Rdtmodules_Specsheetpdf>
</modules>
<frontend>
<routers>
<Specsheetpdf>
<use>standard</use>
<args>
<module>Rdtmodules_Specsheetpdf</module>
<frontName>specsheetpdf</frontName>
</args>
</Specsheetpdf>
</routers>
<layout>
<updates>
<specsheetpdf>
<file>specsheetpdf.xml</file>
</specsheetpdf>
</updates>
</layout>
</frontend>
</config>
<?xml version="1.0"?>
<config>
<modules>
<Rdtmodules_Specsheetpdf>
<active>true</active>
<codePool>local</codePool>
</Rdtmodules_Specsheetpdf>
</modules>
</config>
<?xml version="1.0"?>
<layout version="1.0">
<specsheetpdf_ajax_index>
<block type="specsheetpdf/specsheetpdf" name="root" output="toHtml" template="specsheetpdf/specsheetpdf.phtml" />
</specsheetpdf_ajax_index>
</layout>
$product_name = $_POST['product_name'];
$product_details = $_POST['product_details'];
$product_image = $_POST['product_image'];
$options_html = $_POST['options_html'];
$product_sku = $_POST['product_sku'];
echo $product_name;
我做错什么了吗?非常感谢您的帮助。它奏效了:我发现当我把信息放在这里时,我自己更正了:l。Welp希望这对其他人也有帮助:)
$product_name = $_POST['product_name'];
$product_details = $_POST['product_details'];
$product_image = $_POST['product_image'];
$options_html = $_POST['options_html'];
$product_sku = $_POST['product_sku'];
echo $product_name;