[eluser]RaZoR LeGaCy[/eluser]
Hello all
I am trying to take an item such as a icon and set it to on and off status. So the click on the icon will set it on then off. The backend will talk to the DB and update without refreshing the page.
Simple but I seem to have a mind block on this simple thing.
My controller is
Code:
function index() {
$this->load->model('dev_model');
#Meta Data
$data['ptitle'] = '';
$data['pkeywords'] = '';
$data['pdesc'] = '';
$data['fsentence'] = '';
#Queries
#Body View
$data['body'] = $this->load->view('******',$data,true);
#Template == Never Change ==
$this->load->vars($data);
$this->load->view('********', $data);
}
function update() {
$value = $this->input->post('value');
// Get value from jquery then insert using Active Record
#Meta Data
$data['ptitle'] = '';
$data['pkeywords'] = '';
$data['pdesc'] = '';
$data['fsentence'] = '';
#Queries
#Body View
$data['body'] = $this->load->view('*******',$data,true);
#Template == Never Change ==
$this->load->vars($data);
$this->load->view('********', $data);
}
View is
Code:
[removed]
$(document).ready(function(){
$('.dot').click(function(){
$(this).parent().click(function(e){ e.preventDefault();});
if($(this).attr('src') == '/images/layout/accept.png') {
$(this).attr('src', '/images/layout/cancel.png');
var value = 0;
$.post({
type: "POST",
url: "/controller/update",
data: $("form").serialize(), // get all the form field values
success: function(msg){
alert( "Data Saved: " + msg );
}
});
} else {
$(this).attr('src', '/images/layout/accept.png');
var value = 1;
$.post({
type: "POST",
url: "/controller/update",
data: $("form").serialize(), // get all the form field values
success: function(msg){
alert( "Data Saved: " + msg );
}
});
}
alert('calling: ' + $(this).parent().attr('href'));
alert('value: ' + value);
});
});
[removed]
<div id="container">
<a href="http://127.0.0.1/app.php/Controller/change/1"><img src="/images/layout/accept.png" class="dot"></a>
<a href="http://127.0.0.1/app.php/Controller/change/2"><img src="/images/layout/cancel.png" class="dot"></a>
<a href="http://127.0.0.1/app.php/Controller/change/3"><img src="/images/layout/cancel.png" class="dot"></a>
<a href="http://127.0.0.1/app.php/Controller/change/4"><img src="/images/layout/accept.png" class="dot"></a>
<a href="http://127.0.0.1/app.php/Controller/change/5"><img src="/images/layout/accept.png" class="dot"></a>
</div>
All assistance is welcome. I know it will be something simple as it always is. LoL
Thanks All