Using selectors on data returned from getJSON
Not sure if this should go here or the Using jQuery Plugins forum.
I have the following javascript:
- <script type="text/javascript">
- $(document).ready(function(){
- // autocomplete setup
- $("input[name='search']").autocomplete("inc/php/suggestions.php", { width: 250, selectFirst: false });
- // grab info for result
- $("input[name='search']").result(function(event,data,formatted) {
- var sku = "sku="+formatted;
- $.getJSON("inc/php/results.php", sku, function(data){
- var result = '<tr><td>'+data.sku+'</td><td>'+data.desc+'</td><td class="center">'+data.page+'</td><td class="center">'+data.min+'</td><td class="center">$'+data.list+'</td><td class="center sale">$'+data.sale+'</td><td><input type="text" class="qty" name="qty[]" /></td><td class="center">'+data.uom+'</td><td><span>Delete<span></td></tr>';
- $("#order tbody").append(result);
- });
- $(this).val("");
- });
- $("span").click(function() { alert("Deleting"); });
- });
- </script>
The autocomplete (I'm using
this one) and the getJSON work perfectly. The problem comes when I try to do something with the returned json data. Line 14 won't work for me. Any selectors I try on the returned json data won't work. The selectors still work on items that were there before the json data was returned. I've been staring at this for hours and can't figure out why it won't work. I've tried searching and nothing has come up for me.
Can somebody shed some light on this situation for me? Is there something I'm missing?