Fetch URLSearchparams with 2 params not working - javascript

Why is this not working
fetch("http://localhost:8000/api/calender/"+new URLSearchParams(4)+"/"+ new URLSearchParams("2023- 02-02"))
i tried it with Postman, where its working

Related

React Native - Tesseract.js - Error: Cannot create URL for blob

I am having a problem using the Tesseract.js libary in an React Native App (on the Android Platform). I am currently taking a picture with in the App, saving the image information in a base64 string and trying to pass it the the worker.recognize() function. The string passed to the function is built as followed: data:image/jpeg;base64,MY_BASE64_STRING. I also tried passing a URL to an image and also tried using the absolute path to an image file I'm always getting the same error:
Error: Cannot create URL for blob!
Here is the code I am using for version 2.0.0-alpha.13:
const { TesseractWorker } = Tesseract
const worker = new TesseractWorker({
workerPath: '../../../node_modules/tesseract.js/dist/worker.min.js',
langPath: '../../assets/lang',
corePath: '../../../node_modules/tesseract.js-core/tesseract-core.wasm.js',
})
worker
.recognize(`data:image/jpeg;base64,${data.base64}`)
.progress(info => {
console.log(info)
})
.then(result => {
console.log(result.text)
})
I tried using Versions 1.0.19 and the alpha version 2.0.0-alpha.13
Thank you to you all! ♥
Tesseract.js doesn't support react-native according to this issue.
https://github.com/naptha/tesseract.js/issues/55
Use this library which uses native mobile modules instead. Might not work with expo though
https://github.com/jonathanpalma/react-native-tesseract-ocr

XMLhttprequest not posting (new to it)

I am trying to send data from javascript to a php page using xmlhttprequests.
It is just like sending form data, eventhough I have copied the examples exactly, it doesnt work.
I know the problem lays with the xmlhttprequest since I have tried sending the same data using an html form with POST and that works fine. So the PHP works.
the errors I get using my code are:
POST http://localhost/thissite/post 404 (Not Found)
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
The current file structure I am using equals:
index.php and store.php in the root and than a folder called js with init.js
function sendData() {
var xmlhttp,
url = "http://localhost/thissite/store.php";
if (window.XMLHttpRequest) {
// code for modern browsers
xmlhttp = new XMLHttpRequest();
} else {
// code for old IE browsers
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("post", url, true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send("sitetarget=/thissite/&buttontarget=firstbutton&amount=2");
}
This function is in my init.js file which is linked on my index.php page.
I have tried changing the used URL to:
store.php
/store.php
./store.php
../store.php
http://localhost/store.php
But I think the URL I use should be correct since that is the url I get send to when I post the form. It is also the same as multiple examples I found in questions posted on here and those users didn't have the same errors as me. This is probably me misunderstanding but I am eager to find out what the problem is with my code before I throw my computer out of the window or pull my last hair out.
Thank you for answering if you do!

Can not encrypt a signature using Topaz SigWeb API

I am trying to integrate SigWeb API into my application. I want to use the digital signature in all modern browsers. Now it works only in IE, using ActiveX object. The problem is that I can not use the encryption key.
Let me explain:
Old version js code looks like:
SigPlus1.AutoKeyStart();
SigPlus1.AutoKeyData = "Some Key Data";
SigPlus1.AutoKeyFinish();
SigPlus1.EncryptionMode = 2;
SigPlus1.SigCompressionMode = 1;
var strSignature = SigPlus1.SigString;
New version (using SigWebTablet.js):
AutoKeyStart();
SetAutoKeyData("Some Key Data");
AutoKeyFinish();
SetEncryptionMode(2);
SetSigCompressionMode(1);
var strSignature = GetSigString();
The value of strSignature is passed to the server and converted to .jpg file. On the server side (java) I am using following code:
ClassLoader firma = (com.topaz.sigplus.SigPlus.class).getClassLoader();
sigObj = (SigPlus)Beans.instantiate(firma, "com.topaz.sigplus.SigPlus");
sigObj.autoKeyStart();
sigObj.setAutoKeyData("Some Key Data"); // the same data in front-end
sigObj.autoKeyFinish();
sigObj.setEncryptionMode (2);
sigObj.setSigCompressionMode(1);
sigObj.setSigString(strSignature);
The problem in setSigString method - it doesn't set the new value (with the old code SigPlus1.SigString works), but if I disable setAutoKeyData - it works fine.
The tablet model: T-LBK766SE-BHSB-R
I have found a solution which works for me. Before signature capture it needs to reset the encryption mode, i.e. to call SetEncryptionMode(0)
UPD (05/03/2017). Guys from dev support recommended me to use AutoKeyAddData function instead AutoKeyStart and AutoKeyFinish functions. I have tested and it works for me. I think this better solution of this issue.
http://www.sigplusweb.com/sigwebtablet_autokeydemo.htm

How to display snapshot data from Firebase 3 which was working perfectly in Firebase 2 [duplicate]

Following codebase used to work with firebase 2.3.1 and Angularfire 1.1.3
Var fb = new firebase("https://database name.firebaseio.com");
var fbObj = $firebaseObject(fb.child("users/" + userId));
I upgraded to firebase3.0 and Angularfire 1.2.
As a result, here is how the above code got modified:
var config = {/* ... */};
firebase.initializeApp(config);
var fb = firebase.database().ref();
var fbObj = $firebaseObject(fb.child("users/" + userId))
The above code however threw error such as a.ref is not a function when instantiating fbObj.
Please suggest.
you should not upgrade your firebase to 3.0 because AngularFire upgrade to 3.0 has not been completed.
See Issue in GitHub : https://github.com/firebase/angularfire/issues/718

Issue requesting YouTube API JSON feed via JavaScript in Internet Explorer

I have been using the youtube api and javascript to generate a player area and then arrows that allow the user to click and scroll through videos to play a new one in the player area. This works fine in every other browser except ie, where it appears to be playing up in ie7,8 and 9 but only on some Operating Systems. For example it appears to be fine using the simulator in windows 8.. any help?
JSfiddle: http://jsfiddle.net/9bBCG/ (which for some reason isn't working here, think the json feed may not be working - but the code does work)
Heres the bit where I'm retrieving the feed:
var playListURL = 'http://gdata.youtube.com/feeds/api/users/BadbyMicroMovies/uploads?v=2&alt=json';
var videoURL= 'http://www.youtube.com/watch?v=';
$.getJSON(playListURL, function(data) {
var list_data="";
$.each(data.feed.entry, function(i, item) {
var feedTitle = item.title.$t;
var feedURL = item.link[1].href;
var fragments = feedURL.split("/");
var videoID = fragments[fragments.length - 2];
var url = videoURL + videoID;
var thumb = "http://img.youtube.com/vi/"+ videoID +"/default.jpg";
list_data += '<li><a class="vid-link" href="'+ url +'?rel=0" title="'+ feedTitle +'"><img alt="'+ feedTitle+'" src="'+ thumb +'"</a></li>';
});
$(list_data).appendTo("#youtube-feed");
Any help is greatly appreciated as I am flumoxed!
Internet Explorer only started supporting standard CORS in version 10. If you're using an older version of Internet Explorer, you can't directly request a resource on a different domain using XMLHttpRequest (which is what that $.getJSON() call is doing).
Instead, you need to use an approach like JSON-P, which will also work on other browsers. You can do this by using a $.ajax() call instead of $.getJSON(), and specify the dataType: 'jsonp' parameter, as explain in the jQuery docs.

Categories

Resources