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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:46:12+00:00 2026-06-08T15:46:12+00:00

I have a little problem, I need to send an ajax request to a

  • 0

I have a little problem, I need to send an ajax request to a file.
Here is my HTML File (index.html)

<a id="like" href="./?act=like&id=24" title="Nobody likes this post!">Like</a> &middot; <a id="dislike" href="./?act=dislike&id=24" title="Nobody dislikes this post!">Dislike</a>

And my like.php file:

<?php
if(!is_logged()) {
    header("Location: ./?act=Home");
die();
}
$uid = $user['id'];
$id = $_GET['id'];
if(isset($id)) {
    $query = mysql_query("INSERT INTO ld (auth_id,post_id,val) 
                          VALUES ('".$uid."','".$id."','1')");
    if($query) {
    header("Location: ".$_SERVER['HTTP_REFERER']);
    } else {
    echo "Contatta l'amministratore riportando l'errore 101";
    }
} else {
header("Location: ./?act=Home");
}
?>

And my “ld” table:

== Struttura della tabella ld

|------
|Campo     |Tipo      |Null|Predefinito
|------
|//**id**//|int(5)    |No  |
|auth_id   |varchar(5)|No  |
|post_id   |varchar(5)|No  |
|val       |varchar(1)|No  |
== Dump dei dati per la tabella ld

|5|4|1|1
|6|4|1|1
|7|4|1|1
|8|4|1|1
|9|4|1|1
|10|4|1|1
|12|4|1|1
|13|4|1|1
|14|4|1|2
|20|4|15|1
|23|5|17|1
|29|4|17|1
|30|4|18|1
== Struttura della tabella ld

|------
|Campo     |Tipo      |Null|Predefinito
|------
|//**id**//|int(5)    |No  |
|auth_id   |varchar(5)|No  |
|post_id   |varchar(5)|No  |
|val       |varchar(1)|No  |

I really don’t know how to send an ajax request, and I have also tried to learn ajax but no way, I can’t understand it.

  • 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-08T15:46:13+00:00Added an answer on June 8, 2026 at 3:46 pm

    You should use jquery, it’s actually very simple with it. First include this in your HTML file:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    

    Then add this, it is called a “listner” and it pays attention in this case to when your link is clicked:

    // A # is used since we are using an id to get the element
    // A . is used for a class, but we are using the id at the moment
    $('#like').click(function(e) { // We assign a click listner with a handler (a function)
      e.preventDefault(); // run this to stop it from going to a new page automatically
      $.get('./', {'act' : 'like', 'id' : $(this).attr('data')}, function(e) {
        // Handle success here
      }, 'json'); // expecting a json object back by using echo json_encode(array(...)) in PHP
    });
    

    With my example you will need to change the html to this:

    <a id="like" href="" data="24" title="Nobody likes this post!">Like</a>
    

    And then you could do the same thing with dislike. The {} as the second parameter i did in the $.get is a javascript array as a fyi. Here is the $.get method i used in jquery’s documentation: http://api.jquery.com/jQuery.get/

    For information on what ajax is and how it works check out this article: http://www.webdesignerdepot.com/2008/11/how-ajax-works/

    Feel free to ask for any clarifications

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

Sidebar

Related Questions

I need a little push in the right direction. Here's my problem: I have
I have little unusual problem to solve. I need some hint or links to
I have a little problem, I need to make directory from my c code
i have a little problem and see no solution for it. I need flexible
i have a little problem, i'm searching, but i can't found what i need,
I have a little problem with Jquery getJSON function. my json here { entries:
I have a little problem where need to do a hash of a number
I have little problem with printing data like this, I have written script like
I ran into a little problem and need some help: If I have an
I'm new here on stackoverflow. I have a little problem with my Android app,

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.