Reputation: 21
I am following the sample mentioned @ jsfiddle
When the same code i copied in separate HTML,Javascript and CSS then the same code does not work.
HTML:
<head>
<script src="jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://api.trello.com/1/client.js?key=apllication key"></script>
<script type="text/javascript" src="script.js"></script>
<link rel="stylesheet" href="base.css" type="text/css" media="screen" charset="utf-8" />
<!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script> -->
</head>
<body>
<div id="loggedout">
<a id="connectLink" href="#">Connect To Trello</a>
</div>
<div id="loggedin">
<div id="header">
Logged in to as <span id="fullName"></span>
<a id="disconnect" href="#">Log Out</a>
</div>
<div id="output"></div>
</div>
Script.js content:
$(document).ready(function(){
alert('Welcome to StarTrackr! Now no longer under police investigation!');
console.log("alert printed");
$("#connectLink")
.click(function(){
Trello.authorize({
type:"popup",
name: "from link",
success: function() {
alert("in success");
},
error:function() {
alert("in error");
}
})
});
});
on success , i want to write my function but it does not seem to be calling it. Any thing that I am missing.
Upvotes: 2
Views: 769
Reputation: 380
I had the same issue and figured out that was because I'm trying to authorize from a file://
URL.
Not understanding exactly why but the authorize page doesn't redirect or close popup in that case.
I simply solved the issue by serving my page on localhost with a webserver (I used nodejs in my case with serve-static
module).
Upvotes: 8
Reputation: 523
I'm guessing the browser you are testing this in is IE.
I had experienced a similar problem with the API where the popup window doesn't call the OnSuccess function, but works fine in jsFiddle, which seems to be the problem you are having here.
My solution was to change the type to be "redirect" so that it asks for permission in the same window. This method works fine in IE with the separate files.
$("#connectLink").click(function() {
Trello.authorize({
type:"redirect",
name: "from link",
success: function() {
alert("in success");
},
error:function() {
alert("in error");
}
})
});
Upvotes: 0