# Dynamic Ajax Select works on windows localhost but on linux server doesn't show the cities , cakephp 2.4! :( any tips?

**URL:** <https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624>\
**Category:** Need Help\
**Tags:** help\
**Created:** [August 12, 2021, 3:02pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624 "2021-08-12T15:02:49Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 12, 2021, 3:02pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/1 "2021-08-12T15:02:49Z")

</div>

```auto
// layout default !:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php echo $this->Html->charset(); ?>
<title>
<?php echo $title_for_layout; ?>
</title>
<?php
echo $this->Html->script(''jquery'');
echo $this->Html->meta(''icon'');

echo $this->Html->css(''cake.generic'');

?>
</head>
<body>
<div id="container">
<div id="header">
<h1>Dynamic Select Box Demonstration</h1>
</div>
<div id="content">

<?php echo $this->Session->flash(); ?>

<?php echo $content_for_layout; ?>

</div>
<div id="footer">
footer
</div>
</div>
<?php //echo $this->element(''sql_dump''); ?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<!-- scripts_for_layout -->
<?php echo $scripts_for_layout; ?>
<!-- Js writeBuffer -->
<?php
if (class_exists(''JsHelper'') && method_exists($this->Js, ''writeBuffer'')){ echo $this->Js->writeBuffer(); }
// Writes cached scripts

?>
</body>
</html>

// controller :

<?php

App::uses(''AppController'', ''Controller'');

class HomesController extends AppController {
var $components = array(''RequestHandler'');
var $helpers = array(''Js'');

function beforeFilter() {

$this->loadModel(''Estado'');
$this->loadModel(''Cidade'');
}

function index() {
$this->set(''title_for_layout'', ''Example of dynamic select box with cities and states in Brazil '');
$this->set(''estados'', $this->Estado->find(''list''));
}

public function getPorCidade() {

$bolete = $this->request->data[''Cidade''][''estado_id''];

$this->layout = true;
if($bolete == ''''){
$discriminas = ''<< error >>'';
}else{

$discriminas = $this->Cidade->find(''list'', array(
''conditions'' => array(''Cidade.estado_id'' => $bolete),
''recursive'' => -1
));
}

$this->set(''discriminas'',$discriminas);
$this->layout = ''ajax'';
}

}

// models :

//Home:

<?php

class Home extends AppModel {
public $useTable = false;
}

?>

//Estado:

<?php

App::uses(''AppModel'', ''Model'');

class Estado extends AppModel {

public $displayField = ''uf'';

public $hasMany = array(
''Cidade'' => array(
''className'' => ''Cidade'',
''foreignKey'' => ''estado_id'',
''dependent'' => false,
''conditions'' => '''',
''fields'' => '''',
''order'' => '''',
''limit'' => '''',
''offset'' => '''',
''exclusive'' => '''',
''finderQuery'' => '''',
''counterQuery'' => ''''
)
);

}

//Cidade:

<?php

App::uses(''AppModel'', ''Model'');

class Cidade extends AppModel {

public $displayField = ''nome'';

public $belongsTo = array(
''Estado'' => array(
''className'' => ''Estado'',
''foreignKey'' => ''estado_id'',
''conditions'' => '''',
''fields'' => '''',
''order'' => ''''
)
);

}
?>

// views :

index:

<table width="100%">
</td><td></td>
</table>
<div class="form">
<?php echo $this->Form->create(''Cidade''); ?>
<fieldset>
<legend><?php echo __(''Example of dynamic select box with cities and states in Brazill''); ?></legend>
<?php echo $this->Form->input(''estado_id'', array(''type'' => ''select'', ''options'' => $estados, ''id'' => ''estados'', ''empty'' => ''select a estado'')) ?>
<?php echo $this->Form->input(''cidade_id'', array(''type'' => ''select'', ''id'' => ''cidada'', ''empty'' => ''select a cidade'')) ?>
</fieldset>
<?php echo $this->Form->end(); ?>
</div>
<?php
$this->Js->get(''#estados'')->event(''change'',
$this->Js->request(array(
''controller''=>''Homes'',
''action''=>''getPorCidade''
), array(
''update''=>''#cidada'',
''async'' => true,
''method'' => ''post'',
''dataExpression''=>true,
''data''=> $this->Js->serializeForm(array(
''isForm'' => true,
''inline'' => true
))
))
);

?>

//get_Por_Cidade:

<?php foreach ($discriminas as $key => $value): ?>

<option value="<?php echo $key; ?>"><?php echo /*$key." - ".*/$value;?></option>

<?php endforeach; ?>

* List item

```

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [August 12, 2021, 8:12pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/2 "2021-08-12T20:12:00Z")

</div>

If its working in your local environment then nothing should be wrong with your PHP code.

Are you getting any JS errors in the browser console?

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 12, 2021, 8:28pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/3 "2021-08-12T20:28:16Z")

</div>

![cake](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/1/1f236da84da976e72f5aca40325ced98e0b65988.png)

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [August 12, 2021, 8:32pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/4 "2021-08-12T20:32:17Z")

</div>

Well this screenshot has no JS console present.

Right click in the browser =\> `Inspect` and then go into the `Console` tab.

But anyways these are all general webdev questions and not anything specific to CakePHP

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 18, 2021, 2:23pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/5 "2021-08-18T14:23:48Z")

</div>

![error](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/1/1d01124d7c1abab864848cbce47ee93c4efdd051.png)

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 18, 2021, 2:29pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/6 "2021-08-18T14:29:58Z")

</div>

the views are in place, any ideas?

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 18, 2021, 3:33pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/7 "2021-08-18T15:33:31Z")

</div>

![error2](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/6/65c8079f17c1d8bd2c2dc4cc45e1bf467fca07cc.png)

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 18, 2021, 3:51pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/8 "2021-08-18T15:51:06Z")

</div>

Server using CentOs.

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [August 18, 2021, 6:16pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/9 "2021-08-18T18:16:49Z")

</div>

Well as the error says: Do you have a file located in `app/View/Homes/get_por_cidade.ctp` ?

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 18, 2021, 6:25pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/10 "2021-08-18T18:25:35Z")

</div>

![error3](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/2/2726d4bbe7ef7dca6f6bf89fab3b07ee6ab25adf.png)

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 18, 2021, 6:28pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/11 "2021-08-18T18:28:13Z")

</div>

yes have…!!!

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 18, 2021, 6:36pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/12 "2021-08-18T18:36:56Z")

</div>

![error4](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/5/54e286463b5d5409610216d0ec45650989be59c8.png)

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [August 18, 2021, 7:32pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/13 "2021-08-18T19:32:38Z")

</div>

your file is called `get_Por_Cidade.ctp` not `get_por_cidade.ctp`  
Watch upper and lowercase letters.

Linux generally uses a case-senstiive file-system (which not all operating systems use per default)  
Therefore it could be, that this worked in another OS which used a case-insensitive filesystem

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 18, 2021, 8:04pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/14 "2021-08-18T20:04:44Z")

</div>

It worked master, I changed everything to lowercase (getporcidade) within the controller method, within the script and in the view name and it appeared. I even took the get\_por\_city from the view.

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 18, 2021, 8:07pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/15 "2021-08-18T20:07:45Z")

</div>

![error5](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/1/1f2f60218e848e244f912327d5568646cdbec22e.png)

---

<div class="post-metadata">

**Author:** ![bazulaques](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bazulaques](https://discourse.cakephp.org/u/bazulaques)\
**Post date:** [August 18, 2021, 8:10pm UTC](https://discourse.cakephp.org/t/dynamic-ajax-select-works-on-windows-localhost-but-on-linux-server-doesnt-show-the-cities-cakephp-2-4-any-tips/9624/16 "2021-08-18T20:10:58Z")

</div>

Thank you very much !!
