JQuery $.getJSON appends a question mark to the request URL

Posted by David Neale on Stack Overflow See other posts from Stack Overflow or by David Neale
Published on 2010-05-10T10:01:25Z Indexed on 2010/05/10 10:04 UTC
Read the original article Hit count: 355

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JSON