1

I come to Laravel 4.x from Codeigniter & don't understand Laravel errors messaging. I am trying to load view into a view this is my code

Route

Route::get('widget/addcustomer', 'WidgetController@addcustomer');

Controller

public function addcustomer()
{
    return View::make('widget.addcustomer')->render();
}

Main view.blade.php

<script>
function loadwidget(1, 'formname', 1)
{   
    var widget_url = '<?php echo URL::to('widget'); ?>';

    $.ajax({
        type:'POST',
        url: widget_url+'/'+formname,
        dataType: "html",
        async: false,
        cache: false,
        success: function(response)
        {
            $('#'+divid).html(response);

            if(active==0)
            {               
                $('#'+divid+' :input').attr('disabled', true);              
            }       
        }
    });
    return true;
}
</script>

External view.php

<form id="customer_form">
    <table><tr><td>....</td></tr></table>
</form>

but in fire bug I am getting

{"error":{"type":"Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException","message":"","file":"E:\\xampp\\htdocs\\tt_kickoff\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\RouteCollection.php","line":210}}

and if I hit http://localhost/tt_kickoff/widget/addcustomer it is loading correct html

2
  • post your routes file Commented Jun 20, 2014 at 15:16
  • Route: Route::get('widget/addcustomer', 'WidgetController@addcustomer'); Commented Jun 20, 2014 at 15:17

1 Answer 1

3

Your routes file will have a GET method for addcustomer() - but you are "POST" to the route, so you also need a POST method.

Edit:

So you change

Route::get('widget/addcustomer', 'WidgetController@addcustomer');

to

Route::post('widget/addcustomer', 'WidgetController@addcustomer');

OR change your ajax

type:'POST',

to

type:'GET',
Sign up to request clarification or add additional context in comments.

1 Comment

What is "divid" - I dont see that defined anywhere? Anyway - this fixed your route problem - now you have an ajax problem....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.