Syntax for Activating SPServices onClick

Jun 17, 2012 at 3:11 PM

I am struggling with some basic syntax I am hoping someone will help set me straight on.  I want to add an "I Like It" term using an Onclick event from an image. So far I have something like this but it is not yet working. 

$(".ILikeItImg").click().SPServices({
  operation: "AddTag",
   url: this.url,
    termID: "a712cb7e%2D629b%2D40b3%2Dbe54%2D2f6f7df34c76",
    title: "I Like it",
    isPrivate:true async: true,
    completefunc: function (xData, Status)
{ alert(Status); alert(xData); 
        });
        });

 

Coordinator
Jun 17, 2012 at 5:05 PM

It's going to be something more like this:

$(".ILikeItImg").click(function() {
  $().SPServices({
    operation: "AddTag",
    url: this.url, 
    termID: "a712cb7e-629b-40b3-be54-2f6f7df34c76", 
    title: "I Like it", 
    isPrivate:true,
async: false, completefunc: function (xData, Status) { alert(Status);
alert(xData); } }); });

You'll want to try this synchronously first to make sure it's working. If you don't need to do anything with the results, you can go async.

M.

Jun 17, 2012 at 5:18 PM
You need to change your code so that you give .click() as input a function that is executed only when the user clicks on the '.iLikeItG' : something like:

$(".ILikeItImg").click(function(){
$().SPServices({...});
});

_____
Paul

Sent from mobile device.
Jun 17, 2012 at 5:20 PM
Oops. Sorry. Did not see Marc's response.

_____
Paul

Sent from mobile device.