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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:39:35+00:00 2026-05-31T23:39:35+00:00

I´ve got a star image as <img> . This image has a javascript function,

  • 0

I´ve got a star image as <img>. This image has a javascript function, that is called on click. The javascript method is called addRating(var data). data is the rating number(1-10).

Now in the javascript function, I want to call the php rate_recipe that wants two GET, one for the rating and one for the recipe_id.

How can I “pass” two things to the php? Can I just add two $_GET ?

EDIT1:
this is the code of the php:

            include 'db_connect.php';
    mysql_query("SET NAMES 'utf8'");
    mysql_query("SET CHARACTER SET 'utf8'");
    $rate = mysql_real_escape_string($_GET['rate']);
    $exist = 0;
    $recipes_id = mysql_real_escape_string($_GET['recipes_id']);

.. so now, how can I call it in addRating(var data)?
I want to stay at the same page, just want to do the rate.

  • 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-05-31T23:39:36+00:00Added an answer on May 31, 2026 at 11:39 pm

    If you want to call a PHP function via JavaScript, you’ll need to do so via AJAX. If you’re using plain JavaScript, you’ll use the XMLHttpRequest object:

    • http://en.wikipedia.org/wiki/XMLHttpRequest

    Or if you’re using jQuery (recommended):

    • http://api.jquery.com/jQuery.ajax/

    Now since you’ll be collecting data, the proper convention is to post the data. Here’s an example of how to do it with jQuery:

    $.ajax({
        type: "POST",
        url: "some.php",
        data: "rating=10&id=5997"
    }).done(function( msg ) {
        alert( "Data Saved: " + msg );
    });
    

    Where some.php is the location of your PHP script.

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

Sidebar

Related Questions

Got the following code: $(document).ready(function() { $('a.add-item').click(function() { if ($(this).parent().find('input').attr('value', '0')) { $(this).parent().find('input').attr('value', '1')
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
got a PictureBox (called i_MC) and i draw a simple image (m_ImgMCN) on it
I know this is probably dead simple, but I've got some data such as
I thought this would be pretty simple; basically, it's a 5-star rating system. When
I've got a few tables that literally only hold integers, no words and for
I am new to cocos2d and suddenly got this EXC_BAD_ACCESS, I made a new
I am using a wordpress plugin called GD Star Rating to allow my users
I have got a problem here in terminating the threads. The problem is that
G'day, This is related to my question on star developers and to this question

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.