Javascript requestData undefined despite var set for JSON

I am trying to get the weather via country and city using the openweather api, I have never coded using JSON before so please go easy on me

This is the code I am using:

<script type="text/javascript">
        $(document).ready(function () {
            $('#btnGetWeather').click(function () {
                var requestData = $('#txtCity').val() + ',' + $('#txtCountry').val();
                var resultElement = $('#resultDiv');

                    url : '',
                    method : 'get',
                    data: { q:requsestData },
                    dataType: 'json',
                    success : function (data){
                        resultElement.html('Weather: ' +[0].main + '<br />' + 'Description: ' +[0].description);

The error I get on firebug is that q:requestData is undefined which confuses me, the html for the inputs is below here, I am sure that this is a simple error but I am unsure as to what this is

                <input type="text" id="txtCity">
                <input type="text" id="txtCountry">
    <input type="button" id="btnGetWeather" value="Get Weather Data">
    <br /><br />
    <div id="resultDiv">


A few issues:

  1. There is a typo, you have declared var requestData and used it like requsestData. Remove a extra s between u and e.

  2. method should be POST, and not GET.

As others have pointed out, the cause of the issue is partly due to a typographical error. In the end your request should look something like this:

  'method': 'POST',
  'url': '',
  'data': {
    'q': city + ',' + country,
  'success': success,

The thing you will most likely need to add is your API key. Since October 2015 you'll need an API key to use Open Weather Map's API. Ref:

You can get an API key here:

Then in the data object add the 'APPID' property and set its value to your API key.

Need Your Help

How to find a library with cmake?

linker cmake subdirectory

To link an executable with a library that resides in a standard location, one can do the following in a CmakeLists.txt file:

Mockup tools for developers: balsamiq sketchflow

php sketchflow mockups balsamiq

I got my first real project, but unfortunately it's with a client who doesn't quite know what he wants, which makes it a bit difficult to interact with him.