Diferença entre $ .getJSON () e $ .ajax () em jQuery
Eu estou chamando uma ação do asp.net MVC
public JsonResult GetPatient(string patientID)
{
...
de JavaScript usando jQuery. Os seguintes trabalhos de chamada
$.getJSON(
'/Services/GetPatient',
{ patientID: "1" },
function(jsonData) {
alert(jsonData);
});
enquanto este não.
$.ajax({
type: 'POST',
url: '/Services/GetPatient',
data: { patientID: "1" },
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(jsonData) {
alert(jsonData);
},
error: function() {
alert('Error loading PatientID=' + id);
}
});
Ambos atingem o método de ação, mas o valor patientID é nulo com a chamada $ .ajax. Gostaria de usar a chamada $ .ajax para alguns dos retornos de chamada avançados.
Quaisquer pensamentos apreciados.