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

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

How to save data using ajax request using CGridview in Yii

When I submit button to update it does not save the data.Here in my view.php file -> ` 'id'=>'main-table-grid', 'dataProvider'=>$dataProvider, 'columns'=>array( array( 'name'=>'section_no', ...

Posted Jul 16, 2014 10:49 AM

Saving Data Of Dependent Dropdown - Yii

I am implementing a dependent dropdown and want to save their id in other table (CANDIDATE). I have a table named as DISTRICT which has three columns ID, NAME and CENTER_ID. My other table is CENTER which has two columns ID and...

Posted Nov 28, 2013 11:39 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

How to save data using Ajax and PDO

What I want to do is save all the data - after the user has filled all the forms - using Ajax and PDO. My problem is that my Ajax won't send to user.php. I got an error in the console...

Posted Jun 19, 2014 8:11 AM

Save data using AJAX and CakePHP

I've spent today researching how to save data using an ajax request in cakephp and have got now where, the documentation on the cakephp website seems a bit lacking for this particular topic. I have several sortable lists and I need...

Posted Jun 08, 2011 8:43 AM

Saving data via AJAX, once done only then redirect the user

I am working on a form which is saved via ajax, this part is working perfectly fine. The problem I am having is user looses the data when before saving the form he clicks on another link which redirects the...

Posted Jul 22, 2014 1:34 AM

Display Saved data using ajax in cakephp

I am new to AJAX and trying my first AJAX example. Where am saving data in database and want to display saved data on same page. Followed tutorial http://www.startutorial.com/articles/view/cakephp-and-jquery-2 I could save data in database successfully according to the tutorial but not...

Posted Aug 03, 2014 9:46 AM

Saving Data using Ajax and MVC

I am saving data into SQL Server using jQuery Ajax through MVC and i am passing json data. When my data is small then it is working fine but when my json contains large data it is saying Internal server...

Posted Aug 29, 2014 10:15 AM

How to save data from a JavaScript variable outside the form in PHP/AJAX/jQuery?

PHP newbie here. I want to save a variable (from jQuery) in PHP/MySQL, but this variable is outside the form. The values from the form elements inside the form is being saved fine though. The variable name in this case...

Posted Nov 23, 2013 3:18 AM

Save data of dependent textField CActiveForm Yii

I am implementing a dependent textField and wants to save its id (CENTER_ID) along with the dropdown id (DISTRICT_ID)from which it got populated in a table (CANDIDATE). For this i have structured by database with a table CENTER which has two...

Posted Dec 01, 2013 5:40 AM

Save data to database jquery ajax through repeater

Hello everyone i'm using a repeater to save my data to my database but i''m having a problem, the first button that is repeater is being trigger while the other not can someone help please? can you please check and...

Posted Jan 10, 2014 4:17 AM

Saving data to the database via JQuery .ajax

I am attempting to save 2 pieces of information to the database via JQuery using the .ajax function. I want to save the postID and the userID in WordPress. I think I get the jist of most of the function...

Posted Feb 06, 2014 7:02 AM

Does not save html select data from ajax query to session

I'm creating a form where the users have to select their country and city from a select field, which is dynamically updated corresponding to the actual country selected. However when the form is submitted everything is getting saved successfully except...

Posted Mar 05, 2014 4:25 AM

Save data to database with FileUpload ajax toolkit (multi upload files) asp.net

I want to upload multi files and save some extra data to files. here it's my ASP.net code <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="Server" /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:TextBox ID="txt_Title" runat="server" OnTextChanged="txt_Title_TextChanged"></asp:TextBox> ...

Posted Mar 11, 2014 4:02 AM

TinyMCE ajax to save data

I have seen many posts about tinyMCE and ajax, but i could not get it working - not by triggering tinyMCE.triggerSave(); not by overriding submit and not by triggering tinyMCE.get("elm1").save(); here is my code: $('#ss').submit(function (e) { ...

Posted Mar 05, 2013 5:20 AM

Save Data fromTinyMCE to php using ajax

I am using TinyMCE in my application i want to save the data entered in TinyMCE using ajax to php I have tried using tinyMCE.triggerSave() before send to ajax but when some emoticons | images are added i get the out...

Posted Apr 04, 2014 12:04 PM

Save data to Google Drive Spreadsheet using AJAX

I'm struggling to get it work for last couple of days. I'm writing a JS class which manipulates spreadsheets from user's Google Drive. So far I was able to create a spreadsheet and read an existing one. Now I have...

Posted Apr 26, 2014 12:17 PM

Yii Framework - data undefined - Ajax Javascript

I'm two days trying solve this, but I have no success. I have a page _form.php for my identificacaoEmigrante.php model and a page _form.php for my filiacao.php model. In identificacaoEmigrante model, I have fields like: IdEmigrante nome idConjuge nomeConjuge idFiliacao (FK) and in filiacao model, I have fields...

Posted May 08, 2014 12:36 PM

 
 
Email:

Username:

Password:


Register

Username:

Password:

Login


Forgot Password
Reset my password!