Tuesday 15 May 2012

php - Laravel Simple jquery request and return not working -



php - Laravel Simple jquery request and return not working -

here script

{{ form::open(array('url' => 'register', 'class' => 'form-signin')) }} <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#driver").click(function(event){ $.post("back",{ name: "zara" },function(data) { $('#stage').html(data); } ); }); }); </script> <div id="stage"> stage </div> <input type="button" id="driver" value="load data" />

here route:

route::get('back', function() { homecoming view::make('back'); });

and view has : simple echo

<?php if( $_request["name"] ) { $name = $_request['name']; echo "welcome ". $name; } ?>

when press submit got next error in console

error: {type:symfony\component\httpkernel\exception\methodnotallowedhttpexception, message:,…} file: "d:\xampp\htdocs\mysample\bootstrap\compiled.php" line: 5704 message: "" type: "symfony\component\httpkernel\exception\methodnotallowedhttpexception"

what error doing ?

you need alter route from

route::get('back', function()

to

route::post('back', function()

php laravel laravel-4 laravel-routing

No comments:

Post a Comment