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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:15:18+00:00 2026-06-04T16:15:18+00:00

I have the following code in a page (index.php), it’s composed by just two

  • 0

I have the following code in a page (index.php), it’s composed by just two DIVs, one on the left side (#leftDIV), which contains a form and another DIV (#messages) which will receive error messages, and another DIV (#mapAJAX) on the right side, which contains a PHP script that should send error messages to that #messages DIV.

<div id="leftDIV">
  <form method="post" onsubmit="return false;">
    ...
    Some code here
    ...
    <input type=button value="Cercar" onclick="search();"/>
    <input type=reset value="Esborrar" />
  </form>
  <div id="messages">&nbsp;</div>
</div>
<div id="mapAJAX"></div>

Once the form is submitted a Javascript function is called, it’ll create a XMLHttpRequest object to load a PHP script in the right side, the idea is to reload only the content on the right side every time the form is submitted. Inside this new script (map.php) I do a search in a database and load the results in a map inside this same right DIV.

If any problems occur, I want to show the error inside the #messages DIV I mentioned earlier, but I have no idea how to send those messages to that DIV from the map.php script. Just searching for any DOM element with the #messages id won’t work, because that script doesn’t have ready access to the left DIV.

I have read this post:

PHP/Javascript passing message to another page

But I don’t know how to trigger the showing of the messages, once a new one is generated. So what can I do?

Also feel free to suggest a new title, I’m not sure mine fully describes the problem I’m exposing.

Thank you in advance.

EDIT: As requested, here is the AJAX code found inside the index.php file. This function is called after search() has done a couple checks on the form values. It uses a file called AJAX.js to ease the creation of the XMLHttpRequest.

function loadMap(ciutat, tipusCuina){
  var div = document.getElementById("mapAJAX");
  var oXMLHttpRequest = createXMLHttpRequestObject();
  var url = "mapa.php?ciutat=" + ciutat + "&tipusCuina=" + tipusCuina;

  oXMLHttpRequest.open('GET', url);
  oXMLHttpRequest.onreadystatechange = function(){
    if(oXMLHttpRequest.readyState == 4){
      if(oXMLHttpRequest.status == 200){
        div.innerHTML = oXMLHttpRequest.responseText;
      }
      else{
        alert("Hi ha hagut un problema amb la recepcio del mapa.");
      }
    }
  }

  oXMLHttpRequest.send(null);
}
  • 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-04T16:15:19+00:00Added an answer on June 4, 2026 at 4:15 pm

    PHP cannot really operate on your DOM in this way. You are using Javascript to get the results of a PHP script. So the next step is to put that result into a div in your DOM. You will do this also with Javascript, not PHP. Are you working with a Javascript library like JQuery or Mootools? If so, this is a very simple task.

    • 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 inside the body of my index.php page: echo Begin
I have the following code in my index.php page: // Write the resulting JSON
I have the following code in a php page <div class=vmenu> <div class=first_li><span >Add
I have the following code in the top frame of a two frame page:
I have currently the following code: <li><a href=index.php id=1 onclick=document.getElementById('1').style.background = '#8B4513';>Weblog</a></li> This changes
I have the following code in my main index.php: <div class=form> <?php $oForm =
I have a menu using the following code, <ol id=feature_list> <li><a href=index.php?action=profile class=feature_current>Profile</a></li> <li><a
I have placed the following code at the top of index.php: if (!isset($_SERVER['REMOTE_ADDR'])){ $_SERVER['QUERY_STRING']
I am using wordpress and on the page sidebar.php I have the following code:
In a php page I have following code: if($_REQUEST['c']!=) // I get error on

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.