Sto provando a passare l'array di stringhe a un metodo Web Api che accetta un array di stringhe come argomento. Bellow il mio Web metodo APIPassare array di stringhe come dati in jquery ajax su web API
[HttpGet]
public string HireRocco(string[] hitList)
{
string updateList = string.Empty;
return updateList;
}
mio ajax
var uri = 'http://localhost:16629/api/AssassinApi/HireRocco',
hitList = ['me', 'yourself'];
$.ajax({
url: uri,
type: 'GET',
data: { hitList : hitList },
cache: false,
dataType: 'json',
async: true,
contentType: false,
processData: false,
success: function (data) {
},
error: function (data) {
}
});
È possibile che questo Ajax colpisce con successo il metodo HireRocco
ma hitList
param è ancora nulla. Cosa dovrei cambiare per passare un array di stringhe come param.
'tipo: 'POST''? –
@Rakesh_Kumar: è un metodo GET, comunque se faccio un POST non risolverà il problema – Riki