javascript - JSON string parameter not working -
i'm having trobule json parameter. here's part of code:
<script type="text/javascript"> $("#deco").click(function () { var cap = document.getelementbyid('canvasvideo').todataurl(); var canvas = document.getelementbyid('captimage'); var context = canvas.getcontext('2d'); var imageobj = new image(); imageobj.onload = function () { context.drawimage(imageobj, 0, 0); }; imageobj.src = cap; //var cap = 'hardcoding' ; if hardcode text, , pass parameter, works. $.getjson('/home/decodeqr', { img : cap }, function (iddonante) { document.getelementbyid("result").value = iddonante; }); }); </script>
in server side, i've got following:
[acceptverbs(httpverbs.get)] public jsonresult decodeqr(string img) { var iddonante = getidqr(conversion.base64stringtobitmap(img)); return json(iddonante, jsonrequestbehavior.allowget); }
as mentioned in code, if hardcode parameter works. think problem in variable gets string canvas.todataurl(), not sure.
edit: have mention, now, jsonresult method on server never called, unless hardcode img attribute.
there limit how long url can be. see here: what maximum length of url in different browsers?
you should posting encoded image data server instead.
Comments
Post a Comment