Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
while iam trying to use this jQuery. im facing "401 Unauthorized" error in Chrome & firefox debugger.
i just want to capture the image using webcam and save/display.

What I have tried:

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src='<%=ResolveUrl("~/Scripts/jquery.webcam.js") %>' type="text/javascript"></script>
<script type="text/javascript">
var pageUrl = '<%=ResolveUrl("~/CamTest.aspx") %>';
$(function () {
   jQuery("#webcam").webcam({
      width: 320,
      height: 240,
      mode: "save",
      swffile: '<%=ResolveUrl("~/Scripts/jscam.swf") %>',
      debug: function (type, status) {
         $('#camStatus').append(type + ": " + status + '<br /><br />');
      },
      onSave: function (data) {
         $.ajax({
            type: "POST",
            url: pageUrl + "/GetCapturedImage",
            data: '',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
               $("[id*=MyimgCapture]").css("visibility", "visible");
               $("[id*=MyimgCapture]").attr("src", r.d);
            },
            failure: function (response) {
               alert(response.d);
            }
         });
      },
      onCapture: function () {
         webcam.save(pageUrl);
      }
   });
});
function Capture() {
   webcam.capture();
   return false;
}
</script>
Posted
Comments
Richard MacCutchan 26-Mar-19 5:53am    
I would guess that you need an authorisation key from Google.
Member 14171287 26-Mar-19 7:15am    
Any idea, how to do
Richard MacCutchan 26-Mar-19 7:39am    
Go to the Google api page for the product you are using and check the documentation.
Richard Deeming 26-Mar-19 14:54pm    
The jQuery URL should start with https::
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

jQuery | Hosted Libraries | Google Developers[^]

But there's no reason that should produce a 401 error. The problem is most likely with another part of your script. Try using the network tab of the browser's developer tools to see which resource is failing to load.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900