I would like to make web service which will delete post asynchronusly. I am not sure how to create request in jquery.
This is how I am working now, and it doesn’t work
$(".delete-link").live("click", function(e){
e.preventDefault();
var id = $(this).attr("id");
$.post("app/posts/deleteAjax/", {"id": id}, function(data){
console.log(data);
});
});
My link has class “delete-link”. I created function deleteAjax with parameter ID in file PostsController.php
Cake gives me error that it can’t find file. I am not sure how should I make a call properly and how to handle it
Try giving full path to url like,
Added
If js extension file, then you can define webroot in your layout.ctp and use it in your .js file, like in your default.ctp:
Hope it helps