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

Post Data with Ajax works in Windows not in Apple. Any idea?

On a page I am calling an ASP.NET Web API action as follows: $.post('/api/mail/send/', { '': $('form #mail').val() }).done(function () { $('form #send').addClass('sent').attr('disabled', 'disabled'); $('form #mail').val('') }); On any browser in Windows the code inside the done function...

Posted Oct 08, 2014 11:01 AM

How to redirect to a new view with data using AJAX in MVC?

I have an MVC 5 app, and in my _Layout.cshtml file, I have two input fields and a href attribute, and when the user fills them, and presses the href, I want to redirect to a particular view in my...

Posted Oct 10, 2014 2:39 AM

How to use the data passed with ajax in the php script?

I am not sure how I should use the data passed along with an ajax call in the PHP script. Specifically, here is the code for the ajax call: if (node_selected!=0 & node_selected!=null){ ...

Posted Oct 22, 2014 2:12 AM

Is loading post data with ajax and having the category ID visible in the source unsafe?

In WordPress I am trying to use Ajax to load a few posts from category X with the click of a button. In order to know what posts/category to load from, I have added a "data-cat" attribute to the button, as...

Posted Nov 05, 2014 9:14 AM

How to pass parameter with ajax in data attribute

$.ajax({ url:location.protocol + "//" + location.host +appContext+"?command=cancerconferenceservlet&action=getConferenceDate&diseaseTypeId="+choosediseaseTypeId, type: "POST", ...

Posted Nov 13, 2014 9:55 AM

 
 
Email:

Username:

Password:


Register

Username:

Password:

Login


Forgot Password
Reset my password!