Wondering would this ajax code work within my controller?

I don’t have a computer until tomorrow to test this but just wondering would this work or is there a way to alternate and make it work for ionics framework

url: ‘path/to/servertest.php’,
type: ‘GET’,
data: {
u: Username,
p: Password
success: function (data) {
data = $.parseJSON(data);

    if (data === true) {
        alert('it was true');