I am trying to make a function return data from an ajax call, which I can then use. The problem is that the function itself is called by many objects, for example:
function ajax_submit (obj)
{
var id = $(obj).attr('id');
var message = escape ($("#"+id+" .s_post").val ());
var submit_string = "action=post_message&message="+message;
$.ajax({
type: "POST",
url: document.location,
data: submit_string,
success: function(html, obj) {
alert (html);
}
});
return false;
}
This means that inside the anonymous “successful” function, I have no way to find out what the obj (or id) call is. The only way I can do this is to attach an identifier to the document, but that seems too rude. Is there any other way to do this?
source
share