Ajax: The response from xmlhttp.responseText is displaying the entire inner HTML rather than the specified text needed

This is my Ajax function. It is functioning correctly, however after the function is called, it returns a response containing HTML tags and required text.

Response in value variable "

<br/>
 <font size='1'>
  <table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
   <tr>
     <th align='left' bgcolor='#f57900' colspan="5">
       <span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>
         ( ! )
       </span> 
        Notice: Undefined index: raw_id in C:\wamp\www\ajax\jsvarupdat\remote.php on line         
         <i>
            3
         </i>
     </th>
   </tr>
 </table>
< /font>

Danial"

Required in value variable

"Danial"

function call_funct(str){ 

if (str=="")
  {
  document.getElementById("scat").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
value = xmlhttp.responseText;
    }
  }

xmlhttp.open("post","remote.php?raw_id"+str,true);
xmlhttp.send();  
}

Answer №1

Your current code has a problem with the usage of = in the line

xmlhttp.open("post","remote.php?raw_id"+str,true);

To correct this issue, your code should look like this:

function call_funct(str){ 

   if (str=="")
    {
          document.getElementById("scat").innerHTML="";
          return;
    }
  if (window.XMLHttpRequest)
   {
     xmlhttp=new XMLHttpRequest();
   }
  else
   {
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
 xmlhttp.onreadystatechange=function()
  {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
       value = xmlhttp.responseText;
     }
  }

 xmlhttp.open("post","remote.php?raw_id="+str,true);
 xmlhttp.send();  
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilize fetch API in React to streamline API responses by filtering out specific fields

I have received an API response with various fields, but I only need to extract the description and placeLocation. results: [{placeId: "BHLLC", placeLocation: "BUFR", locationType: "BUFR",…},…] 0: {placeId: "BHLL ...

An error occurred while trying to retrieve the message from the JSON data in PHP/AJ

i have created a form in a PHP file and I am sending a request to another PHP file (test2.php) using AJAX. However, when I receive the data back in AJAX and try to print it in id="txtHint2" (paragraph tag), it shows as undefined. What could be causing th ...

Transferring a JavaScript variable to PHP after it was added using AJAX techniques

First and foremost, I want to express my gratitude to everyone who has provided assistance on this platform. Your support has been invaluable and has helped me navigate through the challenges of completing my thesis. Currently, I am working on an experime ...

Remove class names from CSS and store them in an array

I have a specific HTML file where the CSS is included at the beginning of the document, enclosed within comment tags. My task is to extract the names of the classes located between these comment tags. /* target >> */ .oneClass { ... } .anotherOne { ...

Set the value of one email input to another email input in AngularJS

I'm having trouble trying to link an email input field to another in angularjs without success. Here is what I have attempted so far: <div class="row-fluid"> <div class="control-group span12"> <label for="email">Email</labe ...

The logical operator malfunctions following a computation

var sub_response_type = {"survey_question":["Test lable"],"responseTypeText":"Exit label","select_param_type":[">","<"],"questions_id":["7","8"],"select_param_value":["12","34"],"radio_type":["&&"]}; var order = ['questions_id' ...

Adjust the URL in real-time within an AJAX JSON request

Hey there, I'm fairly new to javascript and ajax. I've been trying to figure this out on my own, but I can't seem to find all the information I need. Currently, I'm making a call to a PHP page using json, and I'd like to be able t ...

use ajax to dynamically load a section of the webpage based on filter criteria

I need to implement a search filter using 3 checkboxes. The search results will be displayed in the div with the id=posts_results <div class="checkbox"> <label><input type="checkbox" id="id1" class="typePost" value="En groupe"> ...

What is the best way to compare a string with a specific object key in order to retrieve the corresponding value?

I'm looking to achieve a relatively simple task, or at least I think so. My goal is to compare the pathname of a page with key-value pairs in an object. For example: if("pathname" === "key"){return value;} That's all there is to it. But I&apos ...

Navigating Angular's Credit Card Input Functionality

I am looking to limit the input capacity to 16 numbers and add a space between each set of 4 numbers. After conducting an extensive search for a credit card input that allows users to enter 16 digits with a " - " or space in between, all results were for ...

What is the process for making changes to a document in Mongoose?

My goal is to allow users to update existing mongoose documents using a form with method-override package. Despite trying various solutions found on Stackoverflow, I have not been able to resolve my issue. The desired functionality is for the user to view ...

Invoking a Directive within another Directive

Feel free to check out this demo on Plunkr. I've set up a basic structure: <body ng-app="myApp"> <div ng-controller="myController"> <parent-directive></parent-directive> <child-directive></child-direc ...

JavaScript: Increasing the date by a certain number of days

I've been researching various topics and so far, I haven't come across one that addresses my specific issue. Here's the task at hand: 1) Extract a bill date in the mm/dd/yy format, which is often not today's date. 2) Add a dynamic ...

What is the method for transmitting multiple data in a single FormData object through Ajax?

My application manages various types of data such as text-box values, label values, drop-down values, file data, and sends this data to the server side for storage in a database. To accomplish this, I initially used a certain method, but now I want to uti ...

Issues with AngularJS edit functionality for records not functioning as expected

I have implemented a feature on my page where users can add objects to an array. These objects are then displayed on the page along with links for editing each item in the array. Each added item is assigned a primary key, allowing users to edit it later e ...

What is the inner workings of stream.Transform in Node.js?

Recently, I stumbled upon a code snippet on a blog showcasing the usage of the stream Transform class to modify data streams and display the altered output. However, there are certain aspects of this code that leave me puzzled. var stream = require(&apos ...

The use of Buffer() is no longer recommended due to concerns regarding both security vulnerabilities and

I'm encountering an issue while trying to run a Discord bot. The code I'm using involves Buffer and it keeps generating errors specifically with this code snippet: const app = express(); app.get("/", (req,res) => { if((new Buffer(req.quer ...

The VueJS component fails to load on the webpage

Here is my Vue.js component code that I am having trouble with. Despite its simplicity, it does not load correctly: Vue.component('my-component', { template: '<div>{{ msg }}</div>', data: { msg: 'hello' ...

Guide to establishing a connection with a Node.js socket server

I'm delving into the world of node JS and experimenting with creating a real-time application that involves a node JS server using socket.io, along with a unity application that can communicate with it. Below is the code I used to set up the server w ...

Replacing all backslashes with forward slashes cannot be done using just one quotation mark; the process involves changing each ""

Struggling to switch all backward slashes with forward slashes " from \ to / . Experimented with numerous possibilities but without success. var a = 'images\1572714983295\10423479\401891269961412\82824649\n.jpg'; ...