Hi all,
I am trying to insert data into my DB, I will need to get this data later on an other page to display but for now I just need it in the DB.
I am having Trouble working out how to get the data in to the function.
Does the code need to be in the Page controller or can I have a different controller for all my ajax methods? (this would be better).
(The page is within a tab too)
I have tried this way.
$('#homeSave').click(function(){
//alert('hey this works');
$.ajax({
async:true,
cache:false,
dataType:'json',
type:'post',
data:{
box1:$('#homeBox1').val(),
box2:$('#homeBox2').val(),
box3:$('#homeBox3').val(),
box4:$('#homeBox4').val()
},
url: "/index.php?r=texHome",
error: function(XMLHttpRequest, textStatus, errorThrown){
dialogObj.dialog('destroy');
dialogObj.attr('innerHTML','<p>There was a problem saving the information</p>');
dialogObj.dialog({
modal:true,
title:'Attention',
buttons:{
'Ok':function(){
dialogObj.dialog('destroy');
}
}
});
},
beforeSend: function(){
dialogObj.dialog('destroy');
dialogObj.attr('innerHTML','<p>Saving...</p>');
dialogObj.dialog({
modal:true,
title:'Please Wait'
});
},
success: function(data) {
dialogObj.dialog('destroy');
dialogObj.attr('innerHTML','<p>Completed</p>');
dialogObj.dialog({
modal:true,
title:'Absences updated',
buttons:{
'Ok':function(){
dialogObj.dialog('destroy');
//$('home_dialog_box').val('hello');
$('#tabs-main').tabs('load',$('#tabs-main').tabs('option', 'selected'));
}
}
});
}
});
});
I have also tried this way
echo CHtml::ajaxSubmitButton(
'Save',
array('/edithome/texHome')
);
Both ways I can not seem to get to work.
Can someone please help going thought the process step by step on how I:
Call a function.
Pass the vars I need to the function.
After I have done all my stuff
return data from the function.
Thanks