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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:49:34+00:00 2026-06-09T20:49:34+00:00

My jquery code is below, This is a currency converting through a API.In the

  • 0

My jquery code is below, This is a currency converting through a API.In the API datas in json. I want to retrieve the data through AJax.

Im geting the error : Fatal error:  Cannot access empty property in C:\xampp\htdocs\mvc\converter\ajax.php on line 25


<script type="text/javascript">
    $(document).ready(function(){
        $("#currency").change(function(){
            var currency= $("#currency").val();
            $.ajax({
                type: "GET",
                url: "ajax.php", 
                cache: false,
                data: currency,
                dataType: "text",
                success: function(data){
                    alert(data);
                    $("#quantity").keyup(function(){
                        //var local_rate= $("#local_rate").val();
                        var quantity= $("#quantity").val();
                        var us_rate= quantity / cur;
                        $('.listprice').html(us_rate);      
                    });
                }
            });


        });
    });
</script>

here is my php (ajax.php) code

<?php
$currency =$_GET['currency'];

$file = 'latest.json';
$appId = '306bdd0f71fe465280e48188846534af';

// Open CURL session:
$ch = curl_init("http://openexchangerates.org/api/{$file}?app_id={$appId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// Get the data:
$json = curl_exec($ch);
curl_close($ch);


$exchangeRates = json_decode($json);

echo $rate= $exchangeRates->rates->$currency;

?>

Im stuck on retrieving the data, without using jquery its working perfectly… In here I want to load through Ajax..

  • 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-09T20:49:35+00:00Added an answer on June 9, 2026 at 8:49 pm

    Change data: currency, to data: {currency: currency}, so the currency will be available via $_GET['currency']

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

Sidebar

Related Questions

So I wrote the code below: jQuery('#contentWrapper').delegate(.addButton, click, function(){ addRow(jQuery(this)); }); function addRow(thisButton){ var
I have this javascript code below that uses jquery, it is suppoed to be
I am using the below jquery code to call a ajax function in my
I have an issue with this jquery code below. Please give me advice or
I have the jquery code below that returns a list of ID's like this
This jquery code below is for a text input box to help users enter
I'm attempting to optimise the jQuery code below, it iterates through all the TD
With this basic jQuery code below, how would I make the on mousout change
I have a jQuery Timepicker code below: $('#timepicker').timepicker({ showOn: 'button', button: '.timepicker_button_trigger' }); This
The jquery code below does exactly what I want it to do on hover.

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.