I have a button on a webpage that I would like to have a form pop up when clicked. The problem is, I have no idea how to pass information for html with ajax. I can successfully pass database information with ajax like so:
View:
def ajax_shipping(request):
id_quote = request.GET.get('quote', None)
quote = HomeTable.objects.filter(id=id_quote).values_list('quote_num_id', flat=True)
items = ItemDetails.objects.filter(quote_num_id=quote).values_list('item', 'quan', 'shipped')
detail_list = []
for x in items:
detail_list.append(x)
data = {
'item': detail_list
}
return JsonResponse(data)
JQuery and Ajax:
$("#id_iden").on('change', function(){
if ($(this).val() !== ""){
var qn = $(this).val()
$.ajax({
url: "/ship/ajax-shipping/",
data: { 'quote': qn },
dataType: 'json',
success: function(data){
if (data.item[0]){
$('#id_item1').val(data.item[0][0])
$('#id_quan1').val(data.item[0][1])
$('#id_ship1').val(data.item[0][2])
var bo = (data.item[0][1]) - (data.item[0][2])
$('#id_bo1').val(bo)
}
}
})
}
})
However, I have no idea how to send form and html information while making it popup. I am looking for a tutorial or some guidance so I can achieve this. Thanks.