<script type="text/javascript">
var $stars = $("#formStars{{ item.url }}")
$stars.click(function(){
var value = $("input:radio[name={{ item.url }}]:checked", this).val(),
item = 开发者_如何学编程"{{ item.url }}",
user = "{{ user }}";
$.ajax({
type: "GET",
url: "/addvote/",
data: "item="+item+"&user="+user+"&value="+value,
success: function(){
$("input:radio[name="+item+"]").attr("disabled", "disabled");
}
});
});
</script>
Don't work the success function, input not disabled, but if i reload the page it becoms disabled...
Try wrapping your function in the a document.ready
$(document).ready(
var $stars = $("#formStars{{ item.url }}")
$stars.click(function(){
var value = $("input:radio[name={{ item.url }}]:checked", this).val(),
item = "{{ item.url }}",
user = "{{ user }}";
$.ajax({
type: "GET",
url: "/addvote/",
data: "item="+item+"&user="+user+"&value="+value,
success: function(){
$("input:radio[name="+item+"]").attr("disabled", "disabled");
}
});
});
);
This makes sure the dom elements are loaded before attempting to manipulate them.
精彩评论