jimmyoneshot Posted September 13, 2011 Share Posted September 13, 2011 Normally if I was to load an ajax response into a page I would load it into a specific div like so:- document.getElementById(mydiv).innerHTML = xmlhttp.responseText; However I want to be able to load in the reponse text AFTER a specific item much in the same way as you would append an item after a specific element I need to append the entire response text after a specific element. Is this possible? Link to comment https://forums.phpfreaks.com/topic/247077-append-ajax-response-text-after-a-specific-item/ Share on other sites More sharing options...
nogray Posted September 13, 2011 Share Posted September 13, 2011 You would first create a new element (e.g. new div) using document.createElement. Append the text in the new element and insert it where you need. You can use the insertBefore method e.g. var dv = document.createElement('div'); dv.innerHTML = 'my text'; var aftr = document.getElement.....; aftr.parentNode.insertBefore(dv, aftr.nextSibling); Link to comment https://forums.phpfreaks.com/topic/247077-append-ajax-response-text-after-a-specific-item/#findComment-1268974 Share on other sites More sharing options...
jimmyoneshot Posted September 14, 2011 Author Share Posted September 14, 2011 Thanks for the advice. I thought that may be the case. Is there any way of doing that without actually creating a div? Not that it matters because that method should be suitable anyway I just don't want to be appending divs unless necessary. Thanks for the help again. Link to comment https://forums.phpfreaks.com/topic/247077-append-ajax-response-text-after-a-specific-item/#findComment-1269034 Share on other sites More sharing options...
Adam Posted September 14, 2011 Share Posted September 14, 2011 Can you rephrase that? As I understood it you're asking to create a DIV, without actually creating a DIV? Link to comment https://forums.phpfreaks.com/topic/247077-append-ajax-response-text-after-a-specific-item/#findComment-1269140 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.