Search code examples
phpjqueryjsonkohanaajaxcontroltoolkit

Failure to return JSON Object with AJAX


(Be aware I am using Kohana 3.1.0, so the framework is automatically routing all the following urls)

I'm using the following (jQuery) to request a JSON object from index.php/functions/submit

    <script type="text/javascript">
        $(document).ready(function(){
            $("#submit_enemy").submit(function(e){
                e.preventDefault();
                var query = $(this).serialize();
                $.getJSON('http://arflux-rpg.com/game/index.php/functions/submit', query, function(data){
                    if (data.success == true)
                    {
                        $('#messages').HTML("<div style='color: #00CE06;'>Success. Enemy \'" + data.name + "\' created.</div>");
                    }
                    else
                    {
                        $('#messages').HTML("<div style='color: #f00;'>Error: " + data.err + "</div>");
                    }
                });
                $('#messages').show(500).fadeOut(1000);
                $('#form_content').show(500);
            });
        });
    </script>

When the URL is routed, it leads to the following PHP code:
http://pastie.org/2104063

Is there something I'm missing?


Solution

  • Looks like your backend can't find the proper view to render:

    throw new Kohana_View_Exception('The requested view :file could not be found', array( //etc