[eluser]Unknown[/eluser]
Everything is working fine on the database end. I just cannot display a CSS element based on content sent from the controller.
I have the following controller (please ignore comments - It works with JSON):
Code:
<?php
class Ajax_test extends Controller {
function Ajax_test()
{
parent::Controller();
}
function index()
{
$this->load->view('ajax_test_view');
}
function process()
{
$this->load->model('Ajax_test_model');
//inside your system/application/models folder, create a model based on the procedure
//outlined in the CI documentation
$record = $this->Ajax_test_model->insert_entry();
//get the record from the database
//$array = array('result' => 'cool dude');
//echo json_encode($array);
echo '<test>bogus</test>';
$this->output->set_header("Content-type: text/xml");
}
}
?>
I am trying to pass
to this view:
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
a.test { font-weight: bold; }
</style>
[removed][removed]
[removed]
$(document).ready(function() {
// hides the slickbox as soon as the DOM is ready
// (a little sooner than page load)
$('#edit').hide();
$('#add-text').hide();
$('#submitted').html("");
$('#submitted').hide();
$('#loader').hide();
// toggles the slickbox on clicking the noted link
$('#edit-text').click(function() {
$('#edit').show();
$('#field').hide();
$('#add-text').show();
$('#edit-text').hide();
$('#submitted').html("");
$('#submitted').hide();
return false;
});
// toggles the slickbox on clicking the noted link
$('#add-text').click(function() {
$('#edit').hide();
$('#add-text').hide();
$('#loader').show();
var dataString = 'name='+ $("#name").val();
$.post("/ajax_test/process", dataString, function(xml) {
$('#submitted').html($("test",xml).text());
$('#loader').hide();
$('#field').show();
$('#edit-text').show();
}, "xml");
$('#submitted').show();
return false;
});
});
[removed]
</head>
<body>
<span id="field">
This is the text to replace.
</span>
<span id="edit">
<input type="text" name="name" id="name" size="25" value="This is the text to replace.">
</span>
<a href="#" id="edit-text">edit</a>
<a href="#" id="add-text">add</a>
<span id="submitted"> </span>
<span id="loader"> <img src="/home/laborlaw/images/ajax-loader.gif" /> </span>
</body>
</html>
for some reason, when I click add, the entry is added to the DB, but the id="submitted" will not display the message from the XML passed from the controller.
Can anyone help me on this?