samedi 3 février 2018

back to (localhost/public/) when the the url is (localhost/public/xxx

i'm facing a problem with my code and i've already found a solution for it but its not convenient for me. when i click on singlepost url the localhost transfer me to 'localhost/myproject/public/singlepost/(id post)' which is exactly what i want. but when i want to comment the post in the previous an error shows up with a message of method not allowed showing url of 'localhost/myproject/public/singlepost/commentpost', my question is how to make the code lead me to 'localhost/myproject/public/commentpost' and not 'localhost/myproject/public/singlepost/commentpost' i hope i made myself clear. thanks for your answers.

here's my ajax:

$('#commentppost').on('click', function(e){    
 e.preventDefault();
 var post_id = $(".hiddenvalue").attr("post_id");
 var post_uid = $(".hiddenvalue").attr("post_uid");
 var comment = $("textarea[name='comment']").val();
 var linkprofile = $(".usernameprofile").attr("href");
 $.ajax({
 headers: {
 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
  url:"commentPost",
  type: 'POST',
  data:{post_uid:post_uid, post_id:post_id, comment:comment},
  success:function(data){
  console.log(data);
   }
  });
  });

my route:

Route::post('/commentPost',array('as' => 'commentPost', 'uses' => 'postController@commentPost'));

ps:the code works just fine when i put url:"http://localhost/dashboard/myproject/public/commentPost", but i dont think thats the best solution to work with



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire