Issues:
You did not close all of your brackets, I assumed you closed the click callback function too early. You did not properly end your brackets. Your ajax call was outside of the scope of the click handler and the ready function.
Note: You need to learn to use indentation, bracket placement and comments to help you see code blocks as different sections of the execution so you can spot things like the ajax call only being fired once (without the correct variables) rather than in that click handler that would allow it to happen multiple times.
You did not need the parenthesizes around your strings in variable assignments.
Edit: This next part is angular specific, not jquery, but not invalid
.ajax() requires data in the post request to be in a string format not in the format of a object.
Solutions:
Reorganized code to show indentation and correct the closures, including the ending }); that was needed.
Removed Parenthesizes, and combined variable declarations into one var statement (readability and efficiency / file size)
It is also a good idea to use 'use strict'
I used $.param(obj)
to format the data being passed.
Code:
'use strict';
$(document).ready( function() {
$("#paybutton").click(function() {
var params = "projectpaymentoption=1197&id=",
usernamepay = window.localStorage.getItem("username"),
paymenturl = params + usernamepay;
$.ajax({
type: 'POST',
url: 'http://www.bla.de/phone/encode.php',
data: $.param({"usernamepay": usernamepay}),
success: function(result) {
console.log(result);
}
}); // end of ajax call
}); // end of #payButton click handler
}); // end of document.ready function