Java 如何通过ajax jquery设置div标记的属性值

Java 如何通过ajax jquery设置div标记的属性值,java,ajax,jquery,Java,Ajax,Jquery,我想设置属性“数据评级”的值。它将使用Ajax <div id="fixed_<s:property value="messageId"/>" **data-rating=**"<%=averageScore%>"></div> from ajax function though jquery that is as below : ` $.ajax({ type : "POST", cache:false, url : '<s:url a

我想设置属性“数据评级”的值。它将使用Ajax

<div id="fixed_<s:property value="messageId"/>" **data-rating=**"<%=averageScore%>"></div> from ajax function though jquery that is as below :

`

$.ajax({
type : "POST",
cache:false,
url : '<s:url action="ratingStatus"/>',
dataType: "text",
data : 'score=' +score+'&messageId='+<s:property value="messageId"/>+'&categoryId='+<s:property value="categoryId"/>+'&threadId='+<s:property value="threadId"/>,
success : function(data) {
alert("inside Success...");

//here i want to set div attribute(data-rating) value from action class response that i have made...



//location.reload();

}
});`

如果有人能在您的成功功能中….

请帮助我

$('#objectID').attr('data-rating', 'your value')
success : function(data) {

 $('#yourdivid').attr('data-rating','value from the response');
}

您的响应是什么样子的?属性的值已经更改,但在刷新jsp页面之前并没有任何效果。所以它不会工作。属性的值已更改,但在刷新jsp页面之前不会生效。所以这不是工作。
$("#fieldId").attr("data-rating","value want to set");