#my_profile is the link id.
function follow(add) {
var data = "data[User][id]="+$("#foloweeId").val();
var actionurl = "/users/users/setFollow";
if(add == 0){
var actionurl = "/users/users/unsetFollow";
}
$.ajax({
type: "post", // Request method: post, get
url: actionurl, // URL to request
data: data, // Form variables
dataType: "json", // Expected response type
success: function(response, status) {
// Response was a success
if (response.success == true){
if(actionurl == "/users/users/setFollow") {
$("#my_profile").html('<a href="#" onclick="follow(0);"
class="submitdemo">Stop Following Artist</a>');
}else{
$("#my_profile").html('<a href="#"
onclick="follow(1);" class="submitdemo">Follow Artist</a>');
}
$("#flashMessage").remove();
$("#content").prepend('<div id="flashMessage"
class="message">'+response.data+'</div>');
}
},
error: function(response, status) {
$("#content").html('<div id="flashMessage"
class="message">Operation faild due to an error</div>').slideDown();
}
});
return false;
}
On Fri, Oct 7, 2011 at 7:52 PM, WebbedIT <[email protected]> wrote:
> AJAX is Javascript and jquery is to Javascript what CakePHP is to PHP,
> i.e. your framework, so why would you want to achieve this without
> using jquery?
>
> Paul
>
> On Oct 4, 10:06 am, heohni <[email protected]>
> wrote:
> > Hi,
> >
> > yes I thought about this poss. But I thought I could find a solution
> > based on cake and not using jquery for it.
> > But thanks for sharing!!
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php