www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to extract a certain div from responseText

  1. #1
    Join Date
    Feb 2009
    Posts
    17

    How to extract a certain div from responseText

    I am just about javascript newbie, so please bear with me!

    I have the following code which I use to fetch an external file and place it within a div tag on current page.

    At the moment, the code successfully fetches the entire file, but I would like to alter it to fetch only a certain div tag from the file, let's say <div id="mydivtag">

    How can I achieve this?

    Thanks in advance!

    Code:
    	mnmxmlhttp = new myXMLHttpRequest ();
    	if (mnmxmlhttp) {
    			mnmxmlhttp.open ("POST", url, true);
    			mnmxmlhttp.setRequestHeader ('Content-Type',
    					   'application/x-www-form-urlencoded');
    
    			mnmxmlhttp.send (content);
    			errormatch = new RegExp ("^ERROR:");
    
    			target2 = document.getElementById (divcontent);
    
    			mnmxmlhttp.onreadystatechange = function () {
    				if (mnmxmlhttp.readyState == 4) {
    					mnmString = mnmxmlhttp.responseText;
    
    					if (mnmString.match (errormatch)) {
    						mnmString = mnmString.substring (6, mnmString.length);
    						target = document.getElementById (divcontent);
    						target2.innerHTML = mnmString;
    					} else {						
    						alert(mnmString);						
    						target = document.getElementById (divcontent);
    						target2.innerHTML = mnmString;
    
    
    					}
    				}
    			}
    		}

  2. #2
    Join Date
    Feb 2009
    Posts
    17
    Anyone?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles