TypeError: r.teams is undefined - Codeigniter + jQuery Ajax + Aropupu Bracket library -


i'm using ajax call in jquery variable server side use in jquery bracket library (http://www.aropupu.fi/bracket/) plugin doesn't recognizes response de server. if use result directly in jquery works fine.

the server side:

function sortear_atletas() {         $competicao_id = $this->input->post('competicao_id');         //example         $atletas = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "l", "m", "n", "o", "p", "q");          if (!empty($competicao_id)) {             $atletasx = null;              $team = $this->sorteios->sortear_grelha($atletas);             $atletasx.= '{"teams": [';             foreach ($team $key => $value) {                 $atletasx.= '["' . $value[0] . '","' . $value[1] . '"],';             }             $atletasx.= ']}';              echo $atletasx;          }     } 

the client side:

$("#gerar_grelha_inscritos_btn").on("click", function () {                     $.ajax({                         url: "<?php echo base_url(); ?>" + "competicoes/grelha_competicao/sortear_atletas",                         data: {competicao_id: competicao_id},                         type: "post",                         success: function (response) {                             $('#minimal').bracket({                                 init: response                             });                          },                         error: function (response) {                             alert(response.error);                         }                     });                 }); 

the view:

<div id="minimal" class="demo"></div> 

the error:

typeerror: r.teams undefined

in ajax request donot specify response type, json,xml etc. on server side echo string. whereas plugin require array.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -