JQuery $.getJSON appends a question mark to the request URL
- by David Neale
I have the folliwng JSON request code on an ASP.NET MVC web application:
var userID = 'id=' + $('#namesList').val();
$.getJSON('/Person/GetPerson/', userID, function(data) {
$('#collar').text(data.collarNumber);
$('#name').text(data.Name);
$('#email').text(data.EmailAddress);
});
This creates a request such as: http://localhost:48610/Person/GetPerson/?id=6. Why is there a question mark in there? I get the server error The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32'....
If I make the request manually without the question mark it works fine.