我正在尝试使用ClearScript(V8ScriptEngine)从c#代码执行javascript函数。这里的Script_Text是javascript代码。我想从jquery调用api并在C#中加载Execute函数,但未定义$之类的异常。如何使用clearscript(V8ScriptEngine)在C#中加载jquery?
C#代码:
public dynamic GetText(string Script_Text, List<object> paraList)
{
V8ScriptEngine _v8Engine = new V8ScriptEngine(V8ScriptEngineFlags.EnableDebugging);
_v8Engine.Execute(Script_Text);
object returnedVal = _v8Engine.Script.Execute();
return returnedVal;
}
JavaScript函数:
function Execute(){
$.ajax({
type: 'GET',
url: "http://172.29.134.69:9006/api/Line/GetStationDefectsByStationIdstationId=1",
success: function (data) {
alert(data);
},
error: function (error) {
alert("Fail");
}
});