Instead of hard-coding the url, try UrlHelper.Action
:
url: '@Url.Action("ChangeVisibility", "Questionnaire")'
A couple other things..
Instead of $(".visibility").attr("checked")
, use this.checked
. The attribute's value doesn't change when the user checks the checkbox.
Also, this should probably be a post
request, not a get
. If it has to be a get
for some reason, use the ajax option cache: false
.