[eluser]Unknown[/eluser]
Hello All,
Its been 2 months since learning and using codeIgniter and I LOVE IT! For me, it's the best way to program web sites.
Anyways here's my question:
I have a
<DIV id="content_panel"> that is populated through a function in my
Controller (ajaxprofile) from a javascript call through a button click.
Javascript Function
Code:
function process() {
var url='http://www.somesite.com/index.php/main/ajaxprofile';
$.post(url, {},
function(pdata){
if (pdata.header=='success')
{
$("#content_panel").html(pdata.content);
}
else {
alert ("failedn\n"+pdata);
}
},
"json"
);
return false;
}
Controller Function
Code:
function ajaxprofile() {
$msg['header'] = 'success';
$msg['content'] = $this->load->view('main/profile_form', '', true);
echo json_encode( $msg );
}
Profile_form.php
Code:
<form id="profile_form" name="profile_form" autocomplete="off" method="get" action="">
<input type="text" name="username" id="username" value="michael" size="20" maxlength="50"/>
<input type="password" name="password" id="password" value="" size="20" maxlength="15"/>
<input class="submit" id="my-button" type="submit" value="Update" style="float:right;"/>
</form>
But it doesn't work. The INPUT submit button isn't bound to the javascript. I think it's because the Javascript is loaded with the page VIEW and the HTML is loaded later when a user clicks a link.
Does anyone know how to work around this? Does this mean I have to somehow reload the javascript?