Welcome Guest, Not a member yet? Register   Sign In
CI jQUERY ajax POST data
#1

[eluser]joeizang[/eluser]
Hi y'all,

Please look at this codeSadI AM SORRY IT'S ALOT OF JQUERY BUT Y'ALL BEEN NICE)

$('ul#navigation li ul li>a').click(function(){
var active = $(this).text();
$('#artcontent p').empty();
$.ajax({
type: 'POST',
url: 'homepage/readarticle',
data: active,
success: function(databack){
$('#artcontent').append(databack);
}
})
});

I have a ul li a that are children of parent ul navigation and li. what I am trying to do is to load an article page. This works but it reads the database and loads all the articles in my database instead of the one identified by active. I would like to know what I am doing wrong or is there a better way to go about this?

Ok the 'homepage/readarticle' is the 'controller/method' in my codeigniter controller which loads the view that renders the article.

As for the serialize line, I actually put in active without the serialize and could catch the text of the link with firebug using the usual console.log(). Like I said, it reads the articles alright but it reads all the articles from my database. instead of fetching the one who's title is equal to the name in the active variable(that would be the text of the link)

This is the php that this calls to:
<?php
function readarticle()
{
$articlename = $this->input->post('active');
$output = $this->articles->displayby_name($articlename);

if($output){
$data['article'] = $output;
}
$this->load->view('loadarticle',$data);
}
?>

Any thoughts?


Messages In This Thread
CI jQUERY ajax POST data - by El Forum - 10-07-2009, 04:13 PM
CI jQUERY ajax POST data - by El Forum - 10-07-2009, 04:27 PM
CI jQUERY ajax POST data - by El Forum - 10-07-2009, 05:08 PM
CI jQUERY ajax POST data - by El Forum - 10-07-2009, 05:26 PM
CI jQUERY ajax POST data - by El Forum - 10-07-2009, 05:43 PM
CI jQUERY ajax POST data - by El Forum - 10-07-2009, 05:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB