Want to build the ChatGPT based Apps? Start here
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
rinku rawat
1.9k
131
16.5k
Ajax call for Web API
Mar 18 2019 6:28 AM
Hi,
How can we pass array type data from ajax to web API.
Web API -
public HttpResponseMessage SearchFileByIDs([FromBody]string[] values)
{
.....
....
...
}
Ajax call -
<script type=
"text/javascript"
>
$(
function
() {
$(
"#btnGet"
).click(
function
() {
debugger
;
let fruits = [
"5c86296afce2d453a8c27d1c"
,
"5c86285cfbaa888204f38fd1"
];
//alert(fruits);
$.ajax({
url:
'http://localhost:8082/api/v1/SearchByIDS'
,
type:
'POST'
,
dataType:
'json'
,
data:
"="
+ fruits,
success:
function
(data, textStatus, xhr) {
debugger
;
console.log(data);
// alert(data.Data.FileUrl);
},
error:
function
(xhr, textStatus, errorThrown) {
console.log(
'Error in Operation'
);
}
});
});
});
</script>
We get fruits id in web api parameter values -
Reply
Answers (
3
)
date range picker
How to wite encrypt and decrypt function