How can I save the value of the title for a row? These are the values of the title=%s:
<a class="false" title=1106 href="/useradminpage?main_id=%s&display=false"><span class="small">(hide)</span></a>
<a class="false" title=1153 href="/useradminpage?main_id=%s&display=false"><span class="small">(hide)</span></a>
<a class="false" title=1175 href="/useradminpage?main_id=%s&display=false"><span class="small">(hide)</span></a>
…
I’ve tried countless variations but none of them work. This is what I have now:
<script>
$(document).ready(function() {
console.log("ready");
$("a.false").click(function(e) {
$(this).closest("tr.hide").hide("slow");
var main_id = a.title;
var display = "false";
e.preventDefault();
});
$("a.false").click(function() {
$.ajax({
url: "/useradminpage?main_id=%s&display=false",
data: {main_id: "main_id", display: "display"},
success: function(data) {
display_false()
alert("4 - returned");
}
});
});
});
</script>
This is the third question on this topic. I appreciate any help. Thanks.
I think what you’re trying to do is pass the value of the
titleattribute along in your AJAX request. If that’s the case, the easiest thing to do will be to do it all in one event handler (is there a reason you’re binding 2 different handlers to the same event?):Your problem currently is that
main_idanddisplayare not in the scope of the second event listener, so will be undefined (and they shouldn’t be quoted, otherwise you’re just passing in strings). As you’re passing in adataobject to theajaxfunction, you don’t really need to add the query string to the URL either.Aside from that, when you assign a value to
main_id, you’re usinga.title. In this caseais undefined, and you will need to usethis, which will be a reference to the clicked element.