Magento自定义jquery ajax不在服务器上工作但在现场工作

时间:2016-02-08 11:28:20

标签: jquery ajax magento server

您好我是磁铁的新手我创建了一个单独的模块,通过jquery ajax复制产品,同时单击产品已在我的本地成功复制的单个产品,而在服务器端它不工作它显示以下错误。

http://example.com/advert_live/index.php/helloworld/index/ 503 (Service Unavailable)

ajax显示上述错误,并且在使用简单的echo代码时,jquery ajax在服务器中工作,同时放置用于复制产品的代码,ajax显示503错误。下面是我复制的产品代码。你能帮我解决这个问题。

<?php
require_once 'app/Mage.php';

umask(0);
Mage::app(‘default’);
class Magentotutorial_Helloworld_IndexController extends Mage_Core_Controller_Front_Action {        
    public function indexAction() {

        $final = $_POST['value'];
        $obj = Mage::getModel('catalog/product');
        $_product = $obj->load($final); 
        $newProduct = $_product->duplicate();
        $newProduct->setStatus(1);
        $newProduct->setSku('value'.$final);
        $newProduct->getResource()->save($newProduct);

    }

}

我在下面调用了jquery ajax是ajax代码

  <script>
                        var jq = jQuery.noConflict();
                        jq(document).ready(function(){
                            jq(".adv_listing_duplicate" ).on( "click", function() {
                                var id= this.id;
                            var uniqu_number = id.split("_");

                            var unique  = uniqu_number[3];

jq.ajax({
            type: "POST",
            dataType: "text",
            data :{'value':unique},
            url :"<?php echo $this->getUrl('helloworld/index',array('_secure'=>true)); ?>",
            success:function(data1){

                alert('Your product have been duplicated succesfully');

              },
    error: function (request, status, error) {
        alert(request.responseText);},

        });
         });
          });
</script>

0 个答案:

没有答案