I have the following jquery:
$.ajax({
url: href,
context: document.body,
success: function (data) {
alert(data);
// Prepare & show dialog
$(dialogDiv).find('.modal-body p.body').html(data);
...
I have some html in ‘data’. I’m sure because I display it in an alert box. I try to inject this html with the last line in the script above. When I inspect the DOM, I don’t see my html in it.
Any idea?
Thanks.
if you defined
dialogDivbefore ajax call (meaning it will be global inside the response method) then why you don’t just usedialogDiv.find('.modal-body p.body').html(data);instead of
$(dialogDiv).find('.modal-body p.body').html(data);Also make sure that
.modal-body p.bodyactually exist before showing the popup.I’m guessing, that your dialog box creates its markup when you showing (or initializing) it.
And here you try to inject html to non-existant element yet.
Try to investigate more, hope it helps.
For a quick check, try first show your dialog and then insert html and see if it’s been inserted.