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

Saturday, March 19, 2022

[FIXED] how to update the existing "part" of a view with a received ajax response , yii 1.1.14?

 March 19, 2022     ajax, jquery, php, yii     No comments   

Issue

The situation is like this: when I first load the page, it displays the data which is powered by a yii widget using e.g

$this->widget(blahblabhablha)

Now, inside that widget, there's clickable dropdown menu, whereby when I click any of the options, I fire an ajax call. Then the backend php script will query the data using the module/controller/action url that I used in the url parameter of $.ajax(). Then I echo json_encode() the data that I fetch from db so that the ajax will get a response.

How to update the widget I just mentioned, using the data response of ajax?, because It's a widget that displays rows and also has pagination, how am I suppose to update that widget to display the data from the ajax response?


Solution

When refreshing grid view for example, Yii actually renders the whole page behind the scenes and then extracts part with gridview div and replaces it. If you are using CgridView, it would be enough for you to set 'ajaxUrl' option when configuring the widget. If not you will have to create html from your ajax response and then place it in the appropriate container via js. Another way, and probably better way is for you to create partial view with only your widget content and then to use renderPartial() in your action to refresh it.



Answered By - Jovana
  • 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