Saving data with Ajax in Yii

Posted Jan 01, 1970 12:00 AM

I've created an ajax action in my controller in order to save a specific data in my post. I dont need to render a view.

my jquery script is doing the following

$("#buttonExtend<?php echo $this->post_row;?>").click(function(e){
            $.ajax({
               type: "POST",
               url: "<?php echo Yii::app()->createUrl('post/extend', array('id' => $data['id'])); ?>",
                          });
        });

and my action extend contains the following

protected function actionExtend($id)
    {
        $model=$this->loadModel($id);



        if(Yii::app()->request->isAjaxRequest) {


            $model->toDate = '10/10/2013';

            $model->save();
    }

}

when I checked the record in mysql, the to_date field is not filled.

even though the updated field, which is updated in my beforevalidate function in the model is updated.

Where is my mistake?

Thank you in avdance for your help

Tagged ajax post data

Similar Topic Questions

TbNavbar containing TbBadge updates with ajax in yii

I am looking to clear the label in tbbadge onclick and update a field in db. The badge is in my tbnavbar. Can i even update it like this? I have also thought of using a widget and get it from...

Posted Jan 02, 2014 12:45 PM

Display updated data with ajax in rails

I have a static_pages_controller with a home method. On the home.html.erb page I have a button: <%= button_to "Refresh recommendations", {action: :home, reset: true},method: :get,remote: true , class: 'btn btn-success'%> When a user clicks the button I want have the controller recompute...

Posted Mar 12, 2014 7:05 AM

How to update data with TbExtendedGridView in yii

I am using TbExtendedGridView in my application and i want to edit fields by using TbEditableColumn. I am not getting how to update corresponding column in mysql table, how to call controller action and how to pass id and edited...

Posted Apr 26, 2014 11:42 AM

Insert data with ajax jquery in asp.net

I don't know what is the problem.. <script type="text/javascript"> $(document).ready(function () { $("#SendCommentBtn").click(function () { ...

Posted Jan 05, 2014 7:15 AM

Saving data via ajax and JSON with Handsontable to Web API

I am sending my Handsontable data via ajax to a Web API POST method, however the data shows up as blank on the web api end. I also used fiddler to see what was being sent and it shows my...

Posted Jan 13, 2014 2:16 AM

Store data in db with ajax in wordpress issues

I've been dealing with this issue for two days now. I've been through all 500 internal server errors to the code alerting that something went wrong. I'm trying to store data in my db through ajax in a module that...

Posted Feb 04, 2014 11:15 AM

Passing data with Ajax, results backslashes in SQL statement

I couldn't find any similar problems. I have a form and the values from the input fields come from a SQL database. When you edit those fields and save the changes, an ajax call is made. In this example, I only use 1...

Posted Feb 20, 2014 8:33 AM

Javascript OOP contructor initializes data with ajax - not available in prototype

I have a problem with implementing a javascript class whose constructor is populated by an ajax call. The data is read from a file and populates correctly the class properties in an asynchroneous manner. The following code works alright: function Pattern(file){ ...

Posted Feb 21, 2014 11:02 AM

Save data to database in Yii Framework using Ajax

I would like to extend the validity of a given post I first list all the post and besides each post, I created a button and when I click, I would like to update the existing toDate and add 1 month. In...

Posted Mar 09, 2014 1:29 AM

Send POST Data with Ajax, withtout form, to a Symfony2 Controller, in JSON format

Good evening everybody! I would like to send JSON Post Data to a Symfony Controller without form, but it doesn't work. I build a JSON data line and it is well built, it is NOT the problem. When I send my...

Posted Apr 27, 2014 9:49 AM

Controller return incorrect data with ajax ActionLink in mvc

Several days ago with searching i put an ajax button inside my page, but i didn't know the issue till now, the thing is happen, is that the result i receive is not the result from ajax redirection, but is...

Posted Jun 03, 2014 5:41 AM

Problems with saving data with single quote ' in the query

I have an asp.net project in which I am getting an error while saving data.I have a text box for school name, most school names get saved but if I have a school name like St.Xavier's, it creates a problem...

Posted Jun 13, 2014 10:29 AM

Hot to make ajax requests with images in Yii

I'am trying to make AJAX request and response with images in Yii and I don't know even where to start. I managed to display images from images folder using db requests for file names. I want to make it so...

Posted Jun 25, 2014 6:50 AM

How to make ajax requests with images in Yii

I'am trying to make AJAX request and response with images in Yii and I don't know even where to start. I managed to display images from images folder using db requests for file names. I want to make it so...

Posted Jun 25, 2014 6:50 AM

How to send/receive XML data with sockets in Qt using string?

I have a Qt TCP Server and Client program which can interact with each other. The Server can send some function generated data to the socket using Qtextstream. And the Client reads the data from the socket using simple readAll()...

Posted Nov 22, 2013 9:00 AM

Laravel 4 how to return multiple view data with ajax and json?

Basically I'm trying to make a popup using this ajax: $.ajax({ type: 'GET' url: 'news/read' dataType: 'json' cache: false timeout: 10000 }).done (msg) -> ...

Posted Nov 24, 2013 6:44 AM

Pagination with ajax in codeigniter

I have problem i will make pagination but my data in the form of an array. i encode data use json_encode and in the view jQuery get data use getJson . so how i can implement pagination in jQuery view...

Posted Nov 24, 2013 6:33 AM

How to retrieve and store data with Ajax

I want to return multiple data (variables) from PHP instead of just 1 piece of returned html code. Right now I got this: $.ajax({ url: "test.php", cache: false }) .done(function(html) { $('video').attr('src', html); }); But I want...

Posted Nov 26, 2013 10:46 AM

Load HTML with ajax in PhoneGap app: will Apple reject?

My Phonegap app calls a database function on the server with ajax. The function returns a html snippet, that I can insert right into the static other html. It's not the case that the whole app's html is loaded externally just a...

Posted Nov 26, 2013 6:08 AM

 
 
Email:

Username:

Password:


Register

Username:

Password:

Login


Forgot Password
Reset my password!