Skip to content Skip to sidebar Skip to footer

Fill Div With Html File Via Ajax

I have a div on my main html file;
and two html files: login.html & singup.html. Also a navigation bar is present on the top of my page. I

Solution 1:

Just get the responeText of the request and set the div.innerHTML = AJAX.responseText;.

If your login.html page built as a stand-alone page, I mean, contains <html><head></head><body>...</body></html> tags - you might want to add just the inner content of the <body> tag. You can use regexp to get it:

div.innerHTML = AJAX.responseText.replace( /<body>([\s\S]*)<\/body>/i , "$1" );

Post a Comment for "Fill Div With Html File Via Ajax"