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 8948231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:56:07+00:00 2026-06-15T12:56:07+00:00

$.ajax({ type : ‘GET’, url : ‘dialog.php’, data: { champion_name:champion_name }, dataType: text, success

  • 0
$.ajax({
    type : 'GET',
    url : 'dialog.php',
    data: {
        champion_name:champion_name
    },
    dataType: "text",
    success : function(data){
        alert(data);
        var dataStr = $(data).find('h2').html();
        $('#champImg').find('div').html(dataStr);

    },
    error : function(XMLHttpRequest, textStatus, errorThrown) {
        alert('failed');
    }
});

I tried to parse returned data in success function because I need to append some elements in one certain div and other elements in other div.

However, $(data).find('h2').html() never works.
I tried every possible way including changing dataType to html, but it is working.

The returned data is valid because I see it alerts html codes from dialog.php successfully. Only $(data).find('h2').html() does not work!

  • 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-15T12:56:08+00:00Added an answer on June 15, 2026 at 12:56 pm

    It fails because there’s no outer element and the selection therefor returns two elements. Find searches then children of the current element but your selection returns two elements one for the image and one for the h2 neither with a h2-child

    if the html had been

    <div>
       <img class='style2' 
            border='2' 
            src='$imgPath' 
            style='width:165px;height:232px;'>   
       <h2>hello</h2>
    </div>
    

    it would work.

    if you can’t/won’t change the returned html you can change the success handle to

    function(data){
      alert(data);
      var dataStr = $(data)[1].html();
      $('#champImg').find('div').html(dataStr);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$.ajax({ type: GET, url: pages.php, data: hash=+s, dataType: html, success: function(msg){ $('#main').append(msg); } Works
$.ajax({ type: 'GET', url: string.txt, cache: false, success: function(str){ alert(Data is: + str); }
I'm using the following code: $.ajax({ type:'GET', url: 'save_desc.php?scrapbook_name=<?php print(addslashes($scrapbook_name)); ?>, success: function(data){ $(#
$.ajax({ type: POST, url: ajax.php, dataType: 'json', data: callback=bumpup_contact_us_entry&id= + id, success: function(data){ $.each(data,
$.ajax({ type: GET, url: something.html, dataType: xml, success:function(data){} , }); The content while accessing
$.ajax({ type: GET, url: awards.xml, dataType: xml, success: parseXml }); function parseXml(xml) { I
$.ajax({ type: POST, url: OMFG.php, data: info, success: function(){ }}); is what I'm using
So I currently use the following: $.ajax({ type: GET, url: file.php, success: function(html) {
I have the following code: $.ajax({ type: GET, url: AJAX.ashx?job=fetch_calendar, dataType: html, success: function
$.ajax({ type: POST, url: add_secondary_interest.php, data: interest=ok, cache: false, success: function(html){ $('#interest_table tr:last').after(html); }

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.