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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:09:27+00:00 2026-06-18T06:09:27+00:00

What i want to do? I am thinking of changing javascript ajax to jQuery

  • 0

What i want to do?
I am thinking of changing javascript ajax to jQuery ajax. It seems shorter, and i saw many people using it, but i can’t really get it working.

What i have so far?
I have an element:
<li id="unique_id" onmousedown="check_element(event, this)">1</li>
When i click on the element, it check which key has been pressed, if its mouse1 then checks background of the element. If element has no background color it changes it to “red” and add id of the element to MySQL database using ajax.
If it had red background already (meaning it was added before) it uses ajax to delete it from database.

Code
Checking function

function check_element(evt, e){
    if(evt.which == 1){
        if(e.style.background == "") {
            e.style.background = "red";
            send_with_ajax("add", e);
        } else {
            e.style.background = "";
            send_with_ajax("delete", e);
        }
    }
} 

Ajax (with javascript):

function send_with_ajax(action, e){
    var xmlhttp;
    if (window.XMLHttpRequest){
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    } else {
        // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    } 
    xmlhttp.open("GET","ajax/send_calendar.php?data="+e.id+"&action="+action+"",true);
    xmlhttp.send();
}

send_calendar.php is nothing out of ordinary. Just grabs variables from $_GET[''] and INSERTS or DELETES values from database. The thing is, how can i change this function to make it jQuery Ajax?

What have i tried?

function send_with_ajax(action, e){
    $.Ajax({
        type: "GET",
        url: "send_calendar.php",
        data: "data="+e.id+"&action="+action+"",
        success: function(msg){
            alert( "Data Saved: " + msg ); //never shows this alert
        }
    });
} 

also i get error:
Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'Ajax'

PS. Never worked with jQuery Ajax before, so i have NO CLUE what i am doing wrong.

  • 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-18T06:09:29+00:00Added an answer on June 18, 2026 at 6:09 am

    It’s $.ajax (case-sensitive), not $.Ajax.

    Also notice, the data option accepts an object as input and $.ajax will do the parameter serialization by itself.

    $.ajax({
        type: "GET",
        url: "ajax/send_calendar.php",
        data: {
            "data" : e.id,
            "action": action
        },
        success: function(msg) {
            alert("Data Saved: " + msg);
        }
    });
    

    There also exist shorthand methods for GET and POST requests, .get() and .post() respectively.

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

Sidebar

Related Questions

Lets say we want a library of javascript-based pieces of functionality (I'm thinking jquery):
I'm thinking of developing a small application using IronPython, however I want to distribute
So I have this layout and I'm planning on using javascript/jquery to change the
I want to implement Scrum, but I can't decide on a Sprint length. Ken
I want to make a user status system and i was thinking to have
I want to use BackboneJS for single page sites. The structure I am thinking
I want to create application which would display spatial data on Map. I'm thinking
I want to be able to replace style=&quot;STUFF&quot; I keep thinking that this is
I am making an abstract-base-class and was thinking I might want a pure virtual
Want to run javascript function from parent window in child window Example I have

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.