vendredi 29 mars 2019

How do i fix this Jquery error 405 (Method Not Allowed)

When i try to debug, i get this error:

jquery.js:6 POST http://localhost/public/product/check-pincode 405 (Method Not Allowed)

I change the jquery version thinking that is the problem, but am still getting localhost error.

jquery

function checkPincode(){

var pincode = $("#chkPincode").val();
if(pincode==""){
    alert("Please enter your Pincode"); return false;
}
$.ajax({
     type:'POST',
     data:{pincode:pincode},
     url:'/check-pincode',
     success:function(resp){
         alert(resp);
     },error:function(){
         alert("Error");
     }
});

HTML

   <P><input type="text" name="pincode" id="chkPincode" placeholder="Check Pincode"><button type="button" onclick="return checkPincode();">Go</button></p>

CONTROLLER

public function checkPincode(Request $request){
     if ($request->isMethod('post')){
         $data = $request->all();
         echo "<pre>"; print_r($data); die;
     }

}

ROUTE

// Check Pincode

Route::post('/check-pincode','ProductsController@checkPincode');



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2UkSmo5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire