XMLHttpRequest ResponseText How to get the content of the specified <div> instead of the entire HTML content

Source: Internet
Author: User
Http_request = new XMLHttpRequest;
....
document.getElementById (reobj). InnerHTML = Http_request.responsetext;

Now that ResponseText is returning the entire HTML, how can I get it to return the contents of my specified tag?

Note: What template, the framework is not used, just loaded a xmlajax.js file in index.php. The above code, in Xmlajax.js, gets the entire HTML code for index.php. How to get the contents of the specified label instead of the entire HTML code!!!



Reply to discussion (solution)

All you have to do is go back to what you need.

is to return only what is needed, the key is how to get responsetext to return only what is needed?

is the URL you requested to be index.php? Return what you need on the server.

Access index.php with Ajax in index.php? The files you access will all be output

Access index.php with Ajax in index.php? The files you access will all be output
Just because all the output, I need not all output, as long as the output part. Can it be solved with regular? If you can, ask the great gods to write a code that matches the entire HTML ... The content in and returns:

Preg_match ("/]+id= ' _ajax ' [^>]*> (. *) <\/div>/is", $str, $arr);
Print_r ($arr [1]);

Aren't you giving yourself trouble?
document.getElementById (reobj). InnerHTML = Http_request.responsetext;
document.getElementById (reobj). InnerHTML = document.getElementById (reobj). getElementById (' _ajax '). InnerHTML

Aren't you giving yourself trouble?
document.getElementById (reobj). InnerHTML = Http_request.responsetext;
document.getElementById (reobj). InnerHTML = document.getElementById (reobj). getElementById (' _ajax '). InnerHTML

I'm not very clear about it. Reobj is _ajax.

Passing ~~~~~~~~~~~ Understand the

So why don't you responsexml, let index.php generate an XML file, and then read the contents of the desired node with the Javascrip Dom!

Regular match

index.php

Can you control the requested file? If you can control what you're going to get back inside.

Pass by, study in ...

Now encountering the same problem

The same problem is now encountered. Distress

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.