[eluser]Paul Hernández[/eluser]
Hi:
I'm developing an app. using ci2. Everything work fine in my development server (apache2, ubuntu 9, mysql). Today I uploaded the code to the production server and the ajax calls do not work anymore. It could be an Apache configuration issue?
Here is the js:
Code:
// Loading jornadas editions
$( function() {
var listados = 'index.php/listados/index',
dataTable,
dataTableOptions = {"bJQueryUI": true};
$( '#tabs' ).tabs({
fx: {height: 'toggle', opacity: 'toggle'}
});
$.ajax({
type: 'POST',
url: 'index.php/home/loadJornadasEditions',
dataType: 'json',
async: true,
success: function( response ) {
//[removed] (response);
if (response == null){
//[removed] (response);
}
else{
for( var i in response ) {
response[ i ].urlLink = 'index.php/form/url' + '/' + response[ i ].formulario_id;
response[ i ].listadosLink = 'index.php/listados/listados_jornada/'+ response[ i ].edicion_jornada_id;
}
//clear old rows (if any)
$('#eJornadas tbody').html('');
//convert json string returned from server into native array of javascript objects
$( '#readTemplate2' ).render( response ).appendTo( "#eJornadas tbody" );
//apply dataTable to #records table and save its object in dataTable variable
//$( '#readTemplate' ).render( response ).appendTo( "#records" );
dataTable = $( '#eJornadas' ).dataTable(dataTableOptions);
//hide ajax loader animation here...
$( '#ajaxLoadAni' ).fadeOut( 'slow' );
}
}
});
//Listados button
$( "#eJornadas" ).delegate( "a.listadosBtn", "click", function() {
formHref = $( this ).attr( 'href' );
[removed].href = $( this ).attr( 'href' );
}); //end delegate
//Form load button. Load the form of the selected jornada edition
$( "#eJornadas" ).delegate( "a.urlBtn", "click", function() {
// formHref = $( this ).attr( 'href' );
[removed].href = $( this ).attr( 'href' );
}); //end delegate
});
The code above make a query to the database that return some info to be place in a table ('#eJornadas').
This is the code of the view:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8"/>
<title>Ediciones de Jornada</title>
<base href="<?php echo base_url(); ?>" />
<link type="text/css" rel="stylesheet" href="css/smoothness/jquery-ui-1.8.2.custom.css" />
<link type="text/css" rel="stylesheet" href="css/styles.css" />
<!-- [removed][removed] -->
</head>
<body>
<div class="message"><?php
// if($message!=""){
//echo $message;
echo $this->session->flashdata('message');
//}
?>
</div>
<br/>
<div id="tabs">
<ul>
<li><a href="#edicionesJornadas">Ediciones jornadas</a>
</ul>
<!-- Edición de jornadas tab -->
<div id="edicionesJornadas">
<table id="eJornadas" class="records">
<thead>
<tr>
<th class="rowNumber">Nº</th>
<th class="nj">Nombre de la Jornada</th>
<th>Edición</th>
<th>Lugar</th>
<th class="fecha">Fecha de inicio</th>
<th class="fecha">Fecha de finalización</th>
<th class="accion">Acción</th>
</tr>
</thead>
<tbody></tbody>
</table>
<br/>
</div>
</div>
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed]
<tr id="${edicion_jornada_id}">
<td>${edicion_jornada_id}</td>
<td>${jornada_id}</td>
<td>${edicion_jornada_nombre}</td>
<td>${pais_id}</td>
<td>${edicion_jornada_fecha_inicio}</td>
<td>${edicion_jornada_fecha_finalizacion}</td>
<td><a class="listadosBtn" href="${listadosLink}">Listados</a> | <a class="urlBtn" href="${urlLink}">URL</a>
</td>
</tr>
[removed]
[removed][removed]
</body>
</html>
And the controller (only the function that is called from ajax):
Code:
public function loadJornadasEditions(){
echo json_encode($this->ej->getJornadasEditions());
And the model (just in case)
Code:
public function getJornadasEditions(){
//get all records from edicionesjornadas table
$this->db->select('ej.edicion_jornada_id, ej.jornada_id, ej.edicion_jornada_nombre, ej.pais_id,
ej.edicion_jornada_fecha_inicio, ej.edicion_jornada_fecha_finalizacion, form.formulario_id');
$this->db->from('ediciones_jornadas AS ej');
$this->db->join('formularios AS form', 'form.edicion_jornada_id = ej.edicion_jornada_id', 'left');
$query = $this->db->get();
if( $query->num_rows() > 0 ) {
return $query->result();
Importance things to notice:
- The response value is null.
- The script is called at the end of the view after de table template
- It works in my local server (on my computer)
Thanks for your help