❔ how to pass multiple arguments in apicall from ajex get url?
i used following approach already
49 Replies
Copied from #web
ok let me try some
none of these work
by the way what is that question mark can you explain me
Ah, that's for passing query parameters
But I see now you're using route parameters
Yeah, I don't think you can do it this way, you need query params
how can i create one
ASP Core should handle the
?foo=1&foo=2&foo=3
way, IIRCi see
With something like
what you are trying to explain
I'm trying to explain how to pass an array of values as a query parameter...?
hello
i have modified my api according to it and now it is like this
but then how should i modifying this
xhr.open('GET',
https://localhost:44385/Exam/GetExamResultByAdmin/${subId}&${Uid}
, true);
But I have to wonder... you're sending two values
Why use an array at all?
brah you are the one who suggested
see
Why not just do
as you did, and have the method on the API side be
Ah, I thought you wanted to send an array of values
If you want to pass multiple values, just use route params
but agin how do i config my xhr.open() so it can send two vals
Angius#1586
Why not just do
as you did, and have the method on the API side be
Quoted by
<@!85903769203642368> from #how to pass multiple arguments in apicall from ajex get url? (click here)
React with ❌ to remove this embed.
It's positional
(also, don't use xhr, use fetch)
Here's the gist of it
Where am I using
?
?nahh bro none of those approch worked
so got just a little bit creative
Show your code
dev-vc-0
join
Just send the code
$paste if it's too much
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
Or link a Github repo
ok git sounds good to me
GitHub
GitHub - digvijay-ship-it/Online-Exam
Contribute to digvijay-ship-it/Online-Exam development by creating an account on GitHub.
And this code
https://github.com/digvijay-ship-it/Online-Exam/blob/main/Online%20Exam%20Web/wwwroot/js/attemptedExamAdmin.js#L105
is supposed to call this
https://github.com/digvijay-ship-it/Online-Exam/blob/main/Online%20Exam%20Web/Controllers/UserController.cs#L63
?
If so, then you haven't read any of the code I sent
So read it again
The part about
[HttpGet]
and the route params defined there
And how the URL looksyes
bro i went to grab my lunch
i thought you would take some time to go through the project son in mean time i thought i can have my lunch
wasn't expecting you to reply this fast
I just found the two places of importance, no need to go through the whole project
In any case
Angius#1586
Quoted by
<@!85903769203642368> from #how to pass multiple arguments in apicall from ajex get url? (click here)
React with ❌ to remove this embed.
Take a look at this again. At the url and the attribute
And see how they differ from what you have
bro is there a way i can use this without fetch
i mean i am new to js so want take it slow
so cant we do that with Xhr object?
Sure can
I just used fetch as an example
The url is what matters
And you should use fetch especially if you're new tbh, xhr is much more complex for no reason
Stick to xhr if you want, tho
that why i like to use it
you see when there are lot megic going around there is less scope of learning
Eh, I guess
Just be advised, that in real life you're not gonna be using xhr
Unless working on some 1999 legacy project that needs to work on Netscape Navigator
ok i will use it this one time
then i will use fetch api from onwards
Sounds reasonable, yeah
ok i changed url and function in controller
but now the system is throwing me an error
after applying this it is throwing this
i tried removing it and then this error stops
Do you route to the controller in some special way? Or do you just let convention take care of it?
If it's the latter, then the name of the method is not a part of the url
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.