Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用JavaScript接收自定义视觉模型的判断结果_Javascript_Azure_Api_Microsoft Custom Vision - Fatal编程技术网

如何用JavaScript接收自定义视觉模型的判断结果

如何用JavaScript接收自定义视觉模型的判断结果,javascript,azure,api,microsoft-custom-vision,Javascript,Azure,Api,Microsoft Custom Vision,我想通过使用JavaScript从Azure自定义Vision模型接收判断结果 我更改了该站点的JavaScript代码 但我不能。 我的代码有什么问题 我更改了IterationId、应用程序、url、内容类型、预测键和数据 这些部分在下面的代码中用{}括起来 <!DOCTYPE html> <html> <head> <title>Human</title> <script src="http://ajax.

我想通过使用JavaScript从Azure自定义Vision模型接收判断结果

我更改了该站点的JavaScript代码

但我不能。 我的代码有什么问题

我更改了IterationId、应用程序、url、内容类型、预测键和数据

这些部分在下面的代码中用{}括起来

<!DOCTYPE html>
<html>
<head>
    <title>Human</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> 
</script>
</head>
<body>

<script type="text/javascript">
$(function() {
    var params = {
        // Request parameters
        "iterationId": "{Iteration id that showed in Performance Page}",
        "application": "{My Project name of Custom Vision}",
    };

    $.ajax({
        url: "{url that showed in "How to use the Prediction API"}" + $.param(params),
        beforeSend: function(xhrObj){
            // Request headers
            xhrObj.setRequestHeader("Content-Type","application/octet-stream");
            xhrObj.setRequestHeader("Prediction-key","{my prediction key that showed in "How to use the Prediction API"}");
        },
        type: "POST",
        // Request body
        data: "D:\some name\some name\image.jpg",
    })
    .done(function(data) {
        alert("success");
    })
    .fail(function() {
        alert("error");
    });
});
</script>
</body>
</html>

人类
$(函数(){
变量参数={
//请求参数
“迭代id”:“{性能页面中显示的迭代id}”,
“应用程序”:“{My Project name of Custom Vision}”,
};
$.ajax({
url:“{url显示在“如何使用预测API”}”+$.param(params),
发送前:函数(xhrObj){
//请求头
setRequestHeader(“内容类型”、“应用程序/八位字节流”);
setRequestHeader(“预测键”,“如何使用预测API”中显示的我的预测键“}”);
},
类型:“POST”,
//请求主体
数据:“D:\some name\some name\image.jpg”,
})
.完成(功能(数据){
警惕(“成功”);
})
.fail(函数(){
警报(“错误”);
});
});
当然,我希望表现出“成功”


但是,实际输出是“error”…

当我在代码中更改此站点的URL()时,我可以获得成功消息。 而且,我也写作 processData:false, contentType:false,
在ajax中的“我的代码”

更改代码以查看返回的错误:

(请注意请求中的新“error”参数)

$.ajax({
url:“{url显示在“如何使用预测API”}”+$.param(params),
发送前:函数(xhrObj){
//请求头
setRequestHeader(“内容类型”、“应用程序/八位字节流”);
setRequestHeader(“预测键”,“如何使用预测API”中显示的我的预测键“}”);
},
类型:“POST”,
//请求主体
数据:“D:\some name\some name\image.jpg”,
错误:函数(xhr、状态、错误){

//>>>>>>>>>>>>>>>>>>>>检查此处错误您收到的错误是什么?不会出现异常消息。“错误”表示调用此代码..失败(函数(){alert(“ERROR”);});