AccountKit SDK was not initialized? - facebook-javascript-sdk

I have a problem with the AccountKit JavaScript SDK ,
When i integrate it with my website it works fine with Firefox but in Chrome it works fine first, but when i try to use it again it gives me this error:
'AccountKit SDK was not initialized. Call AccountKit.init first.'
Any idea?

The idea is to add the initialization immediately after the sdk loads. Seems like when there is much data/code to load before the initialization, it sometimes hangs.
ie
<script src="https://sdk.accountkit.com/en_US/sdk.js"></script>
<script type="text/javascript">
AccountKit_OnInteractive = function(){
AccountKit.init(
{
appId:youID,
state:"{{csrf}}",
version:"v1.1"
}
);
console.log("{{csrf}}")
};
</script>
NOT
<script src="https://sdk.accountkit.com/en_US/sdk.js"></script>
// some code
<script type="text/javascript">
AccountKit_OnInteractive = function(){
AccountKit.init(
{
appId:youID,
state:"{{csrf}}",
version:"v1.1"
}
);
console.log("{{csrf}}")
};
</script>

I have same issue and I solve it. Just call your AccountKit.init your main file(index.html) where your app hold all scripts. From me it looks like this:
index.html
<script src="https://sdk.accountkit.com/en_US/sdk.js"></script>
<script type="text/javascript">
AccountKit_OnInteractive = function(){
AccountKit.init(
{
appId:youID,
state:"{{csrf}}",
version:"v1.1"
}
);
console.log("{{csrf}}")
};
</script>

Can you add in the code that you're using?
https://developers.facebook.com/docs/accountkit/web
You do need to call AccountKit.init as part of the setup.

Related

Javascript Modules Error in ASP.NET Razor Pages

I just tried to do up a quick sample app for modern ASP.NET development and the Javascript is being problematic. As soon as you encounter a library which is exposed as a module (e.g. "qs"), you hit a road-block.
Originally, my code looked like this, with just script tags added to the markup and it was working fine:
#section Scripts {
<script src="https://cdn.jsdelivr.net/npm/vue#2.6.14/dist/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.24.0/axios.min.js"></script>
#*<script src="https://cdnjs.cloudflare.com/ajax/libs/qs/6.10.2/qs.min.js"></script>*#
<script src="./js/main.js"></script>
<script>
main.msg = '#msg';
main.bootVue();
main.init();
</script>
}
But then I added qs and the following error ensued:
"ReferenceError: qs is not defined"
note: captializing the Q does work (as in Qs)
Otherwise, I believe the issue is the fact that qs is exposed as a module.
I'd be keen to learn how I can change my code so that it uses the qs library as intended.
Do I need to introduce 3rd party tooling like Requirejs or Webpack so that the browser understands modules? Or is it possible to just do this simply with raw Javascript.
This is what I have tried so far:
#section Scripts {
<script src="https://cdn.jsdelivr.net/npm/vue#2.6.14/dist/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.24.0/axios.min.js"></script>
<script type="module">
import { main } from "./js/main.js"
main.msg = '#msg';
main.bootVue();
main.init();
</script>
}
And in main.js, there is this:
import { qs } from "../js/qs.min.js"
...
export const main = new Main();
But I get the following js error:
The requested module '../js/qs.min.js' does not provide an export named 'qs'
Am I on the right track, or is there something I am not understanding?
The code using qs is:
sendDate: () => {
axios.post('', qs.stringify({ selectedDate: this.getEpoch(this.selectedDate) }), {
headers: {
RequestVerificationToken: this.antiForg
}}
);
},

how to integrate login with linked in in chrome extension

Does any one know how to integrate linked In Login method with chrome extension?
I am trying to integrate Login in with linked in my chrome extension but have no idea how to do it. i tried this code but it says:
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: xxxxxxxxxxxxx
onLoad: onLinkedInLoad
authorize: true
</script>
<script type="text/javascript">
function onLinkedInLoad() {
IN.Event.on(IN, "auth", getProfileData);
}
function getProfileData() {
IN.API.Profile("me").result(ShowProfileData);
}
function ShowProfileData(profiles) {
var member = profiles.values[0];
var id=member.id;
}
</script>
<script type="in/Login"></script>
Failed to load resource: net::ERR_FILE_NOT_FOUND
I believe you have likely spelled the resource incorrectly. I just ran into the same issue because I was trying to call the file oauth.js but in my directory I had spelled it ouath.js. Double check all your spelling and the paths that you are using to find files.

Auto-Redirecting after BigVideo.js video ends

I'm having trouble auto-redirecting after my video has ended using BigVideo.js. Not sure what's wrong here. Not only does this not redirect it completely breaks the player and the video does not play.
<script type="text/javascript">
var BV;
$(function() {
// initialize BigVideo
BV = new $.BigVideo();
BV.init();
BV.show('vids/video.mp4');
BV.getPlayer().on("ended", function() {
window.location = "http://www.google.com";
})
});
</script>
I tested your code locally and the redirection worked without any problems.
I guess it depends on the browser type/version or other environment factor.
Try to properly unload the video element by:
BV.getPlayer().on("ended", function () {
this.pause();
delete(this);
window.location = "http://www.google.com";
});
reference:
How to properly unload/destroy a VIDEO element
hope that will do the trick :)

on reloading/refreshing the page the dojo/ready function is not called

When refreshing/reloading a page, the dojo/ready function is not called, so the page is not loaded properly. Sometimes it is working properly; some times not.
window.onload = function() {
setTimeout(function(){document.body.style.opacity="100";},100);
require(["dojo/ready"], function(ready){
ready(function(){
alert("ready");
});
});
};
This is my window onload code. Sometimes I am getting the alert ready, sometimes not. I cannot figure out the issue.
Thanks in advance
I'd suggest to not use window.onload.
Instead, include your script as a js file like this:
<script type="text/javascript" src="/appRoot/js/my.js"></script>
Then in your my.js file:
require([ "dojo", "dojo/domReady!" ], function(dojo) {
// Code in here will be run only when the page is ready.
});
I am using this with dojo 1.7, but this is valid through 1.9.
See also the dojo/domReady! documentation.

blueimp Basic Plugin: Not uploading in IE, all versions

I am using the blueimp fileupload basic plugin in my project. It all works well in Safari, Firefox, Chrome but there is a problem with Internet Explorer 9 and below:
The start callback gets called and in the network tab of developer tools I see the ajax call being executed. However the file is never being upload (I checked on the server, too) and the call eventually ends up in a 408 request timeout.
Any hints on what could be the reason?
Here are my relevant code parts:
<input class="input-file" id="fileupload" name="files[]" data-url="/app_dev.php/backend/ajax/upload/wish/1850cf918a43d42" type="file">
<script type="text/javascript" src="js/jquery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="js/uploader/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" src="js/uploader/jquery.fileupload.js"></script>
<script type="text/javascript" src="js/uploader/jquery.iframe-transport.js"></script>
<script>
$(document).ready(function() {
$('#fileupload').fileupload({
dataType: 'json',
dropZone: null,
start: function (e, data){
console.log('start'); //fires in all browsers = fine
},
progress: function (e, data){
console.log('progress'); //fires in Safari, FF, Chrome = fine
},
done: function (e, data) {
console.log('done'); //never getting here in IE cause file doesn't get uploaded.
}
});
</script>
Problem fixed!
There were two issues. One had to do with local network settings.
The other was to implement the correct handling of content type negotiation. See https://github.com/blueimp/jQuery-File-Upload/wiki/Setup for more details.
Just my 5 ยข:
I had a very hard time trying to make it work with pretty links! Following dumps were totally empty!
var_dump($_FILES);
var_dump($_POST);
var_dump($_GET);
So:
$('#fileupload').fileupload({
url: 'http://code.dev/products/postUpload' // <--- remove trailing slash!!!
});