TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
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
Forums
Monthly Leaders
Forum guidelines
ramesh santha
NA
5
921
Undefined value while executing JS function using V8Engine
Dec 21 2018 12:33 AM
I am calling Execute method of javascript function from C# using V8ScriptEngine but i got undefined value in C#.What should i change in Javascript function? How to know callback function is called or not? Also please suggest other ways to call api from Javascript using ClearScript(V8ScriptEngine).
Javascript Function:
function
Execute(paraList){
var
finalUrl =
"http://172.29.134.69:9006/api/Line/GetStationDefectsByStationId?stationId=1"
;
var
response=get(finalUrl,
function
(){
var
resp=
this
.response;
return
resp;});
return
response;
}
function
get(url, callback) {
var
xhr =
new
XMLHttpRequest();
xhr.open(
"GET"
,url,
true
);
xhr.send(
""
);
xhr.onreadystatechange =
function
() {
if
(xhr.readyState == 4) {
if
(
typeof
callback ===
"function"
) {
callback.apply(xhr);}
}
};
}
C# Code:calling javascript function from c# using V8ScriptEngine
V8ScriptEngine _v8Engine =
new
V8ScriptEngine(V8ScriptEngineFlags.EnableDebugging);
_v8Engine.Execute(Script_Text);
_v8Engine.AddCOMType(
"XMLHttpRequest"
,
"MSXML2.XMLHTTP"
);
object
returnedVal = _v8Engine.Script.Execute();
return
returnedVal;
Reply
Answers (
0
)
How to Install Python Flask on linux Red Hat hosting
How to calculate the draggle locationicon to get distance