I am submitting a link using ajax jquery On clicking like like data should be submitted and insted of like it will display dislike
I am facing followiwng problem
1) after submission it is going to next page( it should not go to next page)
2) it is sending null data
i am using following code in jquery
<a href="likeit" id="likeitlink">Like it</a>
var dataString = 'elementId='+ '123'+ '&elementType=' + 'games' +
'&likedBy=' + 'abc';
$(document).ready(function(){
$('a#likeit').bind('click',function(event){
event.preventDefault();
$.ajax({
type: "POST",
url: "likeit",
dataType: "text json",
data: dataString,
success: function() {
$('#likeitlink').html("dislike");
}
});
});
});
in struts Action Class
public class LikeIt extends ActionSupport {
private String elementId;
private String elementType;
private String likedBy;
public String like() {
System.out.println(getElementId() + ", " + getElementType() + ","
+ getLikedBy());
return SUCCESS;
}
}
In actin it is showing all values null
Try using Following