1 回答

TA貢獻1895條經(jīng)驗 獲得超3個贊
在文件dashboard.html中,您必須在模型代碼 ex 中提供 div。<div id="formapp">
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<p>This is Modal Box</p>
<div id="formapp">
</div>
</div>
</div>
在阿賈克斯
$.ajax({
type: "POST",
url: './server/modal.php',
data: {
'leadid': leadid
},
success: function(data){
var result = $.parseJSON(data);
console.log(result);
console.log(result.length)
//Modal Box to POP UP HERE
$('#formapp').empty(); // first empty division content
var form=''; //declare var
$.each(result, function(key, value) {
form = $("<form action='' method='POST'></form>").attr("id", value['Lead_Id']);
//This value assigning based on JSON Key value pair is also not working
form.append('<label>Lead Id: </label><input type="text" name="leadid" value="'+value['Lead_Id']+'">');
form.append('<label>Lead Name: </label><input type="text" name="leadname" value="'+value['FirstName']+" "+value['LastName']+'">');
form.append('<label>Company: </label><input type="text" name="company" value="'+value['Company']+'">');
form.append('<input type="button" value="button">');
i = i + 1;
});
$( "#formapp" ).html( form );
//This change in CSS is not working
$('#myModal').show();
}
});
或者不需要$.each()單條記錄,只需使用result[0]['Lead_Id']
也$form被視為參考。在jquery中使用var聲明變量
- 1 回答
- 0 關注
- 111 瀏覽
添加回答
舉報