I have this code:
$('#customerPaymentTable > tbody > tr').eq(index).after("<tr><td colspan='6'><center>" + $('#customerRecordForm').load(url) + "</center></td></tr>");
The problem is it returns this value object Object instead of the div element. The weird part is if I load the div independently, I mean if I don’t insert it in the table row it is working.
The working code is:
$('#customerRecordForm').load(url);
How am I gonna make it work? I really need that div form to be inserted. Please help. Thanks in advance.
The issue is because
$('#customerRecordForm').load(url);will fill the#customerRecordFormelement with the HTML from the url and then return the jQuery object, not the HTML as a string.You have two options. Firstly, you could change the logic to get the HTML you require from an AJAX call, and then insert that into the table cell., like this:
Alternatively, you could append the cell, and then call the
load()on that new element, like this: