Working with a data variable in a jQuery AJAX operation

I've been attempting to utilize the following code, but it's not functioning as expected: UPDATED WORKING:

$(document).ready(function() { 
    $('.infor').click(function () {
     var datasend = $(this).html();
        $.ajax({
            type: 'POST',
            url: 'http://domain.com/page.php',
            data: 'im_id='+datasend',
            success: function(data){
                $('#test_holder').html(data);
            }
            });
    }); 
});

Even though I used $datasend as the variable for sending data, it doesn't return the value itself, just its name.

Answer №1

To improve the code, I suggest replacing $datasend = $(this).html; with var datasend = $(this).html();

Next, update data: 'im_id=$datasend', to data: 'im_id='+datasend,

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

What could be preventing the fill color of my SVG from changing when I hover over it?

I am currently utilizing VueJS to design an interactive map showcasing Japan. The SVG I am using is sourced from Wikipedia. My template structure is illustrated below (The crucial classes here are the prefecture and region classes): <div> <svg ...

If the data attribute exists, toggle between window.ready and window.ajaxComplete

When HTML includes: data-load-file or data-load-content then it should be handled with: document.ajaxComplete If not, then use: document.ready Currently, two separate files are being used to accomplish this $( document ).ready(function() { ...

Glitch in transmitting server data to client in MERN stack development

I am currently developing a MERN web application and I've encountered a bug in which the data retrieved from the server is not matching what is expected when making a GET request on the client side. Below is the controller function on the server for ...

My React application came to an unexpected halt with an error message stating: "TypeError: Cannot read properties of undefined (reading 'prototype')"

Everything was running smoothly with my app until I encountered this error without making any significant changes: TypeError: Cannot read properties of undefined (reading 'prototype') (anonymous function) .../client/node_modules/express/lib/resp ...

The checkbox is currently selected, however, I would like it to be dese

I am facing an issue where I cannot figure out why the password checkbox always turns to checked even when it is supposed to stay unchecked. No matter what, it doesn't behave as I intended and I am struggling to explain this behavior... <template&g ...

What are some strategies for navigating the constraint of having multiple root elements in Vue.js?

Seeking assistance from the experts here to solve this particular issue. I have a dataset that looks like this: [ { title: 'Header', children: [ { title: 'Paragraph', children: [], }, ], }, ...

What is the best way to loop through ng-repeat with key-value pairs in order to display each

I need to loop through and show the data stored in "detailsController". <div ng-controller="detailsController"> <div ng-repeat="data in details" id="{{data.Id}}"> {{data.Name}} </div> </div> ...

What is preventing me from successfully sending form data using axios?

I've encountered an issue while consuming an API that requires a filter series to be sent within a formData. When I test it with Postman, everything works smoothly. I also tried using other libraries and had no problems. However, when attempting to do ...

Is there a way to store the JWT response header retrieved with fetch?

I am currently utilizing React and employing fetch to send a request to the server: fetch("http://localhost:8001/api/login", { method: 'post', headers: { "Content-type": "application/x-www-form-urlencoded; charset=UTF-8" }, ...

Successfully created a WCF AJAX enabled service, however, encountering a 404 error when trying to call

This is my inaugural WCF service endeavor, so please bear with me. :) I have a preexisting ASP.Net website that has been functioning adequately thus far. Utilizing VS 2017, I integrated a new WCF Ajax-enabled service. VS generated the .svc and .cs files a ...

Obtain pictures from Google image search using Python

As a newcomer to web scraping, I initially turned to https://www.youtube.com/watch?v=ZAUNEEtzsrg for guidance on downloading images with specific tags (e.g. cat), and it proved successful! However, I have encountered a new issue where I can only download a ...

Issues with Dynatree loading on Internet Explorer 9

Having integrated a dynatree into a web application, the dynatree is generated from the server using a JSON object. The dynatree functions perfectly on updated versions of Firefox, Safari, Chrome, and Opera, but I encounter an issue with Internet Explorer ...

How to resolve the error of "Cannot GET /api/courses/1"

const express = require('express'); const app = express(); app.get('/',(req,res) =>{ // viewable at localhost:3000 res.send('hello world'); }); app.get('/api/courses',(req,res) =>{ // shown on ...

Verify the Javascript for file upload in ASP.NET folder prior to uploading it

Struggling with this problem for days now, I could really use some fresh perspective. My setup includes Windows Server 2012, IIS 8.0, and ASP.NET 4.5. I'm new to both IIS and ASP.NET, so please bear with me. The website I'm working on involves f ...

Leverage React.js by incorporating a Header-Imported JavaScript Library

I recently developed a React.js web application and am exploring the use of Amplitude Analytics, which provides a Javascript SDK found here. According to the guidelines, I need to include a <script></script> within the <head></head> ...

Issue encountered when making API requests in JavaScript that is not present when using Postman

Currently, I am developing a web application using express and one of the functionalities is exposed through an API with an endpoint on 'api/tone'. This API acts as a wrapper for one of Watson's services but I choose not to call them directl ...

Ways to establish whether the element $(this) is present in an array during a click event

I am currently working on populating 4 arrays with a set of id values. Each array will eventually be assigned text values for an h1 and a p element, but for now I am focusing on setting up an alert when one of the images in the array named graphicDesign is ...

Enhancing this testimonial slider with captivating animations

I have designed a testimonial slider with CSS3 and now I am looking to enhance it by adding some animation using Jquery. However, I am not sure how to integrate Jquery with this slider or which plugins would work best for this purpose. Can anyone provide g ...

Encountering an unusual issue while implementing collision detection with THREE.Raycaster in version r68

Up until now, I've successfully utilized the THREE.Raycaster in my game engine for testing collisions across various elements. It has been reliable and effective. However, a puzzling issue has recently arisen that has left me stumped. Despite believi ...

The count of records in MongoDB by the current month

Recently delving into MongoDB, I found myself in need of a way to retrieve the count of posts made in the current month. Keeping timestamps true in my PlateModel model, it appears as follows: { timestamps: true } The current code snippet in my Controller ...