I'm sending an ajax request like so:
$.ajax({
type: "GET",
url:"/game/set",
data: JSON.stringify({colour: col, size: size}),
success: function(){console.log("SUCCESS.")},
dataType: 'json'
});
I can receive the request on the server just fine, but I can't figure out how to pull the data from it before responding. He is how I'm handling it.
var jsonString = '';
req.setEncoding('utf8');
req.on('data', function (data) {
jsonString += data;
});
req.on('end', function () {
reqData = JSON.parse(jsonString);
respond(200, JSON.stringify(reqData));
});
but I seem to get this error when trying to parse.
SyntaxError: Unexpected end of input
You can't send data in a GET
request. Try POST
instead.