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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:01:07+00:00 2026-05-27T00:01:07+00:00

I have modeled an AJAX search after this example a long time ago. I

  • 0

I have modeled an AJAX search after this example a long time ago. I have changed some things – the whole request process is handled now via jquery. But the PHP file which is requested is basically the same. I have added an header for multibyte compatibilty…

header("content-type: text/html; charset=utf-8");

but other than that: little edits. And it worked quite well. Until recently: I wanted to switch to strict XHTML and have been transforming my html code. And I mean strict: I have even changed the MIME type to “application/xhtml+xml”. The only problem: When switching to this type, the AJAX search isn’t working anymore. The problem is not jquery, it is PHP’s DOMDocument class. Here is the central simplified portion of the PHP file, which is requested via jquery

if (mb_strlen($searchTerm) > 2) {

  $xmlDoc = new DOMDocument('1.0', 'UTF-8');

  $xmlDoc->load('data.xml');

  echo 'Results:<br />';

  $x = $xmlDoc->getElementsByTagName('data');

  for($i=0; $i<($x->length); $i++) {

    $name=$x->item($i)->getElementsByTagName('name');

    if ($name->item(0)->nodeType==1) {

      $name = $name->item(0)->childNodes->item(0)->nodeValue;

      if (mb_stristr($name,$searchTerm)) echo $name .'<br />';

    }

  }

} else {

  echo 'Searchterm to short';

}

The problem lies not with jquery, because, when I input 2 letters into the input field which triggers the AJAX request, the returned text is ‘Searchterm to short’ (so request is basically wokring). Now comes the confusing part: When I type a word, which should be found in the XML file, nothing is returned: no error, no text, no nothing. When I type a word which isn’t in the XML file, at least ‘Results:
‘ is returned. So it seems: PHP is looping through the XML file somehow. When I switch with the whole project to the content type “header(‘content-type: text/html; charset=utf-8’)” everything is working fine again. Do I have to change the mime type of the requested PHP file, too – I have already tried different variations without success. Do I have to change the DOMdocument object somehow to get it working in a strict XHTML enviroment…?

  • 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-05-27T00:01:07+00:00Added an answer on May 27, 2026 at 12:01 am

    I’m quite embarrassed. The AJAX request output breached the strict XHTML rules. Just haven’t seen it. The example above would run without problems, because I’ve stripped some of the flawed HTML code. However: problem solved, own stupidity confirmed…

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

Sidebar

Related Questions

Well, I have been beating my head over this one for some time now,
I have an Android app modeled after the LunarLander example by Google. I am
I have a database application in which a group is modeled like this: TABLE
Have a n-tire web application and search often times out after 30 secs. How
I have a modeled a set of objects that correspond with some real world
I currently have the following javascript code (loosely modeled after how a similar objective
I have this scenario and I'm not sure exactly how it should be modeled
Here is my problem with simplified example. I have two entities modeled from SQL
I have done some research on this question and most answers are a few
I currently have an assembly program which is modeled after the hexdump system function

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.