Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:38:05+00:00 2026-06-17T18:38:05+00:00

I have an ajax post sends a website address to php it retrieves it

  • 0

I have an ajax post sends a website address to php it retrieves it and then I want jquery to find certain elements within the site and retrieve the text in those elements. It works fine for a few elements like h1 h2 p a etc but not on all sites and I can’t get body text and meta tags i.e. body.text returns nothing. Is it my ajax post or php causing the problem here?

Here is my ajax post

var dataString = name;

            $.ajax({
      type: "POST",
      url: "senddom.php",
      data: {"dataString" : dataString },
      dataType: "json",
      success: function(response) {
  $('body').append("<p> contents of title:" + $(response).find("Title").text()+ "</p>");          
  $('body').append("<p> contents of meta:" + $(response).find('Meta').text()+ "</p>");      
  $('body').append("<p> contents of all: " + $(response).find('body').text() + "</p>");

 $(response).find('p').each(function() {
  $('body').append("<p> contents of p: " + $(this).text() + "</p>");
});

and my php which I have only started learning

<?php 
    $site= $_POST['dataString'];             // get data
function curl_get($site){
    $useragent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$site);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);   
    $data=curl_exec($ch);
    curl_close($ch);
    return $data;
}

function getdom($site){
    $html = curl_get($site);
    // Create a new DOM Document
    $xml = new DOMDocument();
    @$xml->loadHTML($html);
   echo json_encode($html);  
}
echo getdom($site);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:38:07+00:00Added an answer on June 17, 2026 at 6:38 pm

    On jQuery doc, I found something interessing.
    We can’t use .text() method on script. So I’m pretty sure, you got script in your body, and so .text() doesn’t work.
    Use .html(), it should work.

    http://api.jquery.com/text/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which sends an AJAX POST to a php file
I have a jQuery AJAX post request that is unexpectedly triggering the error callback
I'm having problems with understanding how jQuery create headers for ajax post. I have
I want to have a set of checkboxes that use AJAX to post to
I have grabbed some XML data using this piece of jQuery: $.ajax({ type: POST,
Hi I have the following code with jQuery: function reject(id) { $.ajax({ type: 'POST',
I have a PHP contact form that I'm using with jQuery's AJAX method, but
I have a nice looking slideup/slidedown jquery form on my website. It sends the
I have a situation where I send jquery ajax post request but in my
setup: cakephp, jquery 1.8.7, cakephp.bee.pl ajax helper I have a website who is set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.