I have an MVC2 EditStatesController :
public JsonResult GetStates()
{
string statesToReturn = GetStates(); // returns "1: Alabama; 2: Alaska; 3: Arizona; 4: Arkansas"
return Json(statesToReturn);
}
this is the code that calls the controller:
//get States
var listOfStates = $.ajax({
url: '/EditStates/GetStates',
type: 'POST',
async: false,
success: function(data, result) {
if (!result)
alert('Failure to retrieve States.');
}
}).responseText;
The dropdown has the list of elements, but last element has extra " (double quote), so the last state Wyoming is Wyoming".
I searched other questions, but didn't find a similar one. Do you know why this is happening and how to fix this? Thank you, Jenny