I have been trying to save the value from an input into a variable which then is saved into another variable which holds a api call url, which is then tied to a getJSON function, for some reason I cannot seem to save the value of the input into the variable, it keeps replying back as blank, but in console it shows up as what the input value holds. What am I doing wrong?
Update: Below is the image of the url not including the saved variable. It should show what I had input into the variable in the full url. As you can see login_name= is blank and so is login_password.
jsFiddle: https://jsfiddle.net/m25pLka5/
HTML:
<form id="sso-login">
<table>
<tr>
<td>User Name:</td>
<td><input class="username" name=login_name type=text size=15 maxlength="100"></td>
</tr>
<tr>
<td>Password:</td>
<td><input class="password" name=login_password type=password size=15 maxlength="100"></td>
</tr>
<tr>
<td>Remember Me:</td>
<td><input name=remember_me type=checkbox></td>
</tr>
</table>
<input type="submit" value="Submit" name="Submit" />
</form>
jQuery:
$(function(){
var username = $('.username').val();
var password = $('.password').val();
var ssoURL = 'https://testing.com/';
var ssoMethod = 'testingMethod&login_name='+ username +'&login_password='+ password +'&v=1.0&response_format=json';
$("#sso-login").submit(function(e) {
e.preventDefault();
$.getJSON(ssoURL + ssoMethod, function(data) {
console.log(data);
});
});
});

??var=somthing&var1=somthing?in the url.