PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 20, 2022

[FIXED] Ajax button in Cgridview doesn't work

 January 20, 2022     php, yii, yii-extensions     No comments   

Issue

I have CGriview with ajax button,but when i click on the button, the page refreshed and doesnt send ajax parameter to my action,my code is like this:

enter code here
array(
                        'class'=>'CButtonColumn',
                        'template'=>'{reset}',
                        'buttons'=>array(
                            'reset'=>array(
                                'label'=>'reset',
                         'url'=>'Yii::app()->controller->createUrl("place/viewHallModal/",array("row"=>"1"))',
                                'options'=>array(
                                    'class' => 'btn',
                                        'ajax'=>array(
                                            'type'=>'post',
                                            'url'=>'js:$(this).attr("href")',
                                            'update'=>'#section-update',
                                            'success' =>'js:function(data) {alert("suc");}'
                                        )), 
                             ),
                        ),

                ),

Solution

I haven't 50+ reputation for commenting, so I can help you only with answering to the question.

In jQuery you can write this ajax function like this

...
$.ajax({
   type: 'post',
   url: 'your_url_will_goes_here',
   cache: false, // or true
   data: {
      'your_data': $variable,
      'your_data1': $variable1,
   },
   success: function(data){
      alert("success !");
});
....

but I couldn't see your data ajax function. So which data you want to pass to your action?



Answered By - Mirjalal
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing