Hello Andrew,<br> I suspect you might have a scoping problem, Sometimes you might see a weird behavior of eventhandler calls when you try to access the data referenced out of its scope.<br><br><div class="gmail_quote">On Tue, Oct 27, 2009 at 7:19 PM, Andrew Stewart <span dir="ltr"><<a href="mailto:boss@airbladesoftware.com">boss@airbladesoftware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
$('#samples .results a.add').livequery('click', function(event) {<br>
event.preventDefault();<br>
// AJAX to add the sample to the story.<br>
$.ajax({<br>
type: "POST",<br>
url: '/stories/2716/loans',<br>
data: {'loan[sample_id]':sample_id}, // <- this sometimes doesn't get sent<br></blockquote><div><br>Where is sample_id ?, in which scope? <br><br>You might want to try something with <a href="http://pastie.org/671711">scoping</a>, like this...<br>
<br> $('#samples .results a.add').livequery('click', function(event) {<br>
<br> event.preventDefault();<br>
<br> var your_sample_id_goodness = sample_id_that_comes_from_well_bound_scope;<br><br> return function(){<br> // AJAX to add the sample to the story.<br>
$.ajax({<br>
type: "POST",<br>
url: '/stories/2716/loans',<br>
data: {'loan[sample_id]': your_sample_id_goodness, <br>
beforeSend: function() { sample.remove(); },<br>
success: function(data) { $('#basket table tr:last').after(data); }<br>
});<br> }(); //End of return<br> <br>
});<br><br>Regards,<br>Abhishek Parolkar<br><a href="http://www.ohloh.net/accounts/parolkar">http://www.ohloh.net/accounts/parolkar</a><br><br><br><br><br><br></div></div>