function ajax() { var isbool = false; let xhr = new XMLHttpRequest(); xhr.onload = function () { if (xhr.status == 200 && xhr.status < 300) { isbool = true; } } xhr.open('GET', "https://jsonplaceholder.typicode.com/posts", true); xhr.send(); return isbool; }
var isonline = await JSRuntime.InvokeAsync<bool>("ajax");
Isonline return false because invokeAsync return false before complete the Onload event. I need return value after complete js function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)