I have a bootstrap accordion list generated from database records. Each entry has a checkbox that when clicked, opens a modal window and data is entered.
When submitted, an ajax database update happens and the modal closes.
Rather than refresh the parent page, I want to return the updated values and change that particular accordion entry with the results.
I get the data returned correctly, but am having problems updating the entry using the following code;
success: function(data) {
var received = data
var resp = received.split('|');
$.each(resp, function( index, value ) {
alert( index + ": " + value );
});
var orderid= $('#modalinvOrder').val();
var notes = '#notes' + orderid;
var files = '#files' + orderid;
var inv = '#inv' + orderid;
alert(notes);
$('#output').html(resp[1]);
$(notes).html(resp[2]);
alert($(notes).val());
$(files).html(resp[3]);
$(inv).attr('checked',true);
The each loop shows the values returned correctly.
the first alert shows the name of a span where I want to display notes returned from the update.
The second alert shown nothing.
How do I address the individual entry and it's elements.
Here's an example of the accordion entry
<div class='panel panel-primary'>
<div class='panel-heading'>
<h4 class='panel-title'><a data-toggle='collapse' data-parent='#accordion' href='#accordion836'><span class='bu'>BM</span><span id='BO6527' class='po'>BO6527</span><span class='orderdate'>17/04/2015</span><span class='total'>£4,250.00</span><span class='supplier'>Lafitte</span></a>
<input type='checkbox' id='del836' data-order='836' class='delcheck' >
<input type='checkbox' id='inv836' data-order='836' data-po='BO6527' data-bucode='LMDQBM-Borough Market' data-supplier='Lafitte' class='invcheck' >
</h4>
</div>
<div id='accordion836' class='panel-collapse collapse '>
<div class='panel-body'>
<p><span class='depart'>Duck </span><span class='total'>£4,250.00</span><span class='delnotes'><strong>Delivery Notes</strong></br>
<span id='notes836'></br>
</br>
<strong>Invoice Notes</strong></br>
</br>
2015-04-20 - Euros </br>
2015-06-25 - Updated </span></p>
<span class='depart filenames' id='files836'></span> </div>
</div>
</div>
Regards
Pete
1 个答案:
答案 0 :(得分:0)
尝试详细了解您获得的orderid。听起来$('#modalinvOrder').val()没有回复你的想法。 .val()用于get values from form elements;要从其他类型的元素(p,span等)获取文本,请使用.text()。 #modalinvOrder是否有某种形式的输入?