Question

I have a problem with my Yii Form-Submission via Ajax: Everything worked fine on my local machine but on the Webserver I always get the error Alert...

The Ajax Error is thrown every time the function is called... although the data is properly POST'ED and the function in the URL did what it should.. So basically everything works but the Ajax Error is thrown every time

SO here is my code:

function merge()
  {     
    var productA = $('#Product_selected_product').val();
    var productB = $('#product_dd').val();

    <?php echo CHtml::ajax(
            array(
                'url'=>CController::createUrl('product/companyItems'),
                'data'=>array('productA' => 'js:$(\'#Product_selected_product\').val()', 'productB' => 'js:$(\'#product_dd\').val()','checker' => 'erwin'), 
                'type'=>'post',
                'dataType'=>'json',
                'error'=>"function() { alert('ERROR'); }",
                'success'=> "function(){window.location.href = '../product/'+productB+''}"
            )
        );


    ?>
    return false; 

}

The companyItems Action searches for entrys in a table with the ID of ProductA and replaces it with the ID of ProductB.

Controller Action : CompanyItems:

public function actionCompanyItems(){
    if(isset($_POST['checker'])) {
            $productA = $_POST['productA'];
            $productB = $_POST['productB'];

            $commandMerge = Yii::app()->db
            ->createCommand("UPDATE ebay SET product_id = :productB WHERE product_id=:productA")
            ->bindValues(array(':productB' => $productB ,':productA' => $productA))
            ->execute();

            $commandDelete = Yii::app()->db
            ->createCommand("UPDATE product SET is_deleted = '1' WHERE id = :productA")
            ->bindValues(array(':productA' => $productA))
            ->execute();            
    }

I hope someone can help me....

Dave

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top