serialize returns nothing

serialize returns nothing

I can't get the serialize function that is supposed to create a query string to work.
My HTML contains one form with one input of type "text" inside it.
Both of these return an empty string.

var queryString = $('form').serialize();
var queryString = $('#myInputId').serialize();

What could I be doing wrong?