I want to make a connect four game with the option to play online against another person connected to my game which is hosted through localhost (within the same WiFi). It's possible to play a game on both computers but not against each other.
Firstly I want to get a simple string send from one client to the other with an ajax call. My attempt:
$(".column").click(function () {
$.ajax({
url: "GetBoard",
method: "GET",
data: { "currentplayer" : currentPlayer },
success: function (data) {
alert("success");
}
});
)};
The controller method I used:
[HttpPost]
public ActionResult GetBoard(string currentPlayer)
{
return View(currentPlayer);
}
I don't really understand how to send data with ajax or how to receive and work with it within a controller.