Welcome Guest, Not a member yet? Register   Sign In
jquery (ajax) post to controller to model (and back) to view problem
#1

[eluser]alienfaceful[/eluser]
I have jquery set up to bind "click" to a bunch of song-title links and the name for each link is that song's id in a database that holds lyrics (I want to output those lyrics eventually)...

$(document).ready(function() {
$('a').click(function(){
$.post('change_lyrics', { id: this.name});
});
});

"change_lyrics" is my controller (called "blog") function...

function change_lyrics() {
$data['title'] = 'Lyrics';

$song_id = $this->input->post('id');
$this->load->model('Musicmodel');
$data2['query2'] = $this->Musicmodel->get($song_id);

$this->load->view('header', $data);
$this->load->view('lyrics_view2', $data2);
$this->load->view('footer');

}

the model takes that song id and returns database info (as an array) to the controller, as a part of $data2. This worked when I defined $song_id explicitly as some number so the problem seems to be that "change_lyrics" is not receiving the posted id from the jquery script or that $data2 is not update automatically in $this->load->view (but that seems crazy- I'm so confused).

Huge thanks in advance for considering this stuff.


Messages In This Thread
jquery (ajax) post to controller to model (and back) to view problem - by El Forum - 06-13-2010, 02:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB