Ein Treffpunkt für C#-Programmierer
Anonymous
Wie bekomme ich Daten von Js fetch() auf den Server?
Post
by Anonymous » 18 Dec 2025, 22:45
Ich versuche, Daten von js auf den Server zu übertragen, erhalte aber „null“.
Mein js:
Code: Select all
async function sort(param) {
let classList = param.classList;
//"DateCreate" //Ascending
console.log(param.id + " " + classList[0]);
let response = await fetch("/Amendment/Sort", {
method: "POST",
body: JSON.stringify({ sortValue : param.id, sortType : classList[0]})
});
if (response.ok) {
let responseHtml = await response.text();
document.getElementsByClassName("result").innerHTML = responseHtml;
alert("OK");
} else {
alert("Error HTTP: " + response.status);
}
Im Browser:
Servermethode (Controller: Änderung):
Code: Select all
[HttpPost]
//null //null
public IActionResult Sort(string sortValue, string sortType )
{
//*****//
return PartialView("_TableData", model);
}
1766094357
Anonymous
Ich versuche, Daten von js auf den Server zu übertragen, erhalte aber „null“. Mein js: [code]async function sort(param) { let classList = param.classList; //"DateCreate" //Ascending console.log(param.id + " " + classList[0]); let response = await fetch("/Amendment/Sort", { method: "POST", body: JSON.stringify({ sortValue : param.id, sortType : classList[0]}) }); if (response.ok) { let responseHtml = await response.text(); document.getElementsByClassName("result").innerHTML = responseHtml; alert("OK"); } else { alert("Error HTTP: " + response.status); } [/code] Im Browser: [img]https://i.sstatic.net/bWiKO.png[/img] Servermethode (Controller: Änderung): [code] [HttpPost] //null //null public IActionResult Sort(string sortValue, string sortType ) { //*****// return PartialView("_TableData", model); } [/code]
0 Replies
56 Views
Last post by Anonymous
17 Jan 2025, 08:13
0 Replies
31 Views
Last post by Anonymous
25 Feb 2025, 09:05
0 Replies
27 Views
Last post by Anonymous
23 Aug 2025, 23:12
0 Replies
35 Views
Last post by Anonymous
25 Feb 2025, 07:24
Kratzerdaten mithilfe von Netzwerk, Fetch, Antwort
by
Anonymous »
26 Aug 2025, 08:57 » in
Python
Ich versuche, die Daten von der Website zu kratzen, wobei asmbcd = variiert von 1 bis 200. Fethch/XHR -> Antwort sehen. import requests
from bs4 import BeautifulSoup
url =
response =...
0 Replies
6 Views
Last post by Anonymous
26 Aug 2025, 08:57