To apply a command to an issue i'm using this code:
$.ajax({
async: false,
type: 'post',
url: "https://golaservices.myjetbrains.com/youtrack/rest/issue/"+e.target.id+"/execute"+"?command="+target.val(),
cache: "true",
dataType: "html"
});
but that brings up this error
You have no access to this resource. Try to log in.
that's why i tried putting that first bit of code like this:
$.ajax({
async: false,
type: 'post',
url: "https://golaservices.myjetbrains.com/youtrack/rest/user/login?login=xxx&password=123",
cache: "true",
dataType: "html",
success: function(output, status, xhr) {
alert(xhr.getResponseHeader('Set-Cookie'));
}
}).done(function (data) {
console.log("in done");
$.ajax({
async: false,
type: 'post',
url: "https://golaservices.myjetbrains.com/youtrack/rest/issue/"+e.target.id+"/execute"+"?command="+target.val(),
cache: "true",
dataType: "html"
});
console.log("after done");
});
but i still get the same error, any idea how to do this ?
/rest/user/login endpoint has been deprecated for a while already and is not recommended for further use. Try permanent tokens instead, they don't require any preflight login requests to be executed.
$.ajax({
type: "post",
url: "https://golaservices.myjetbrains.com/youtrack/rest/issue/" + e.target.id + "/execute" + "?command=" + target.val(),
dataType: "json"
beforeSend: function(xhr) { xhr.setRequestHeader("Authorization", "Bearer " + permanentToken); },
});
Related
i use laravel 5.8 and i have a a problem if i insert or update a page than i go not back to the page list.
postcontroller :
i use : return response()->json('Post Created');
and i use a ajax file whit this code :
$.ajax({
type: 'POST',
url: this.action,
data: new FormData(this),
dataType: 'json',
contentType: false,
cache: false,
processData:false,
success: function(response){
Sweet('success',response)
success(response)
},
error: function(xhr, status, error)
{
$('.errorarea').show();
$.each(xhr.responseJSON.errors, function (key, item)
{
Sweet('error',item)
$("#errors").html("<li class='text-danger'>"+item+"</li>")
});
errosresponse(xhr, status, error);
}
})
});
i get a nice message if it is insert or updated but it not go back to my list, hope you understand what i mean.
if you want to redirect after success do something like this:
$.ajax({
type: 'POST',
url: this.action,
data: new FormData(this),
dataType: 'json',
contentType: false,
cache: false,
processData:false,
success: function(response){
Sweet('success',response)
success(response)
window.location.href = "url you want to redirect to";
},
error: function(xhr, status, error)
{
$('.errorarea').show();
$.each(xhr.responseJSON.errors, function (key, item)
{
Sweet('error',item)
$("#errors").html("<li class='text-danger'>"+item+"</li>")
});
errosresponse(xhr, status, error);
}
})
});
I am having a problem while using cross-origin ajax.
I know it's a common question but did not get any solution for it yet.
$.ajax({
type: "GET",
url: url,
data: {id:id},
dataType: "jsonp",
crossDomain: true,
contentType: "application/jsonp; charset=utf-8",
async: false,
success: fnsuccesscallbackk,
error: function(xhr, error){
alert(error);
},
jsonpCallback: fnsuccesscallback
});
function fnsuccesscallback(data){
alert(data)
}
…but getting undefined response in callback function.
Is there anything wrong what I am doing.
After a lots of RND finally i got the solution of this.
Ajax function:
$.ajax({
type:"GET",
url:'https://www.url.com/welcome/test_js',
data:{name:'xyz'},
crossDomain:true,
dataType: "jsonp",
jsonp: 'fnsuccesscallback',
success: function(data) {
alert(data.name)
}
});
In the Php function:
function test_js() {
echo $_GET['fnsuccesscallback'] . "(" . json_encode($_GET) . ")";
}
I have an ajax call such as:
$.ajax({
url: "/query/",
dataType: 'script',
cache: true,
data: {
"" : url,
},
cache: false,
//...
});
whereas: url: "/query/
is a clean URL.
When I make the request i get an URL such as:
http://domain.net/api/query/?=www.whatever.com&_=1434580542713
how could I remove the "?=" section in order to get an URL such as:
http://domain.net/api/query/www.whatever.com&_=1434580542713
Many thanks in advance,
$.ajax({ url: "/query/"+url, dataType: 'script', cache: true, data: {}, cache: false,
I have tried for a day now so I will post - does anyone know why the following code for posting follow relationship using Instagram API wont work?
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: 'https://api.instagram.com/v1/users/<user-id>/relationship?access_token=' + instagramaccesstoken,
data: JSON.stringify({ "action": "unfollow" }),
dataType: "jsonp",
cache: false,
beforeSend: function () {
$("#loading").show();
},
success: function (data) {
alert(data);
$("#loading").hide();
}
});
If you replace the <user-id> placeholder in your URL with a real user ID, then it will work.
Hello guys i have the next ajax call for login. I serialize the form and send the data to server and return redirect url link. My problem is that my url after post is like
http://localhost:50802/?username=&password= and not http://localhost:50802/Home
$.ajax({
type: "POST",
url: "Login/Login",
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: loginJson,
cache: true,
async: false,
complete: function (result) {
alert(result.link);
window.location.replace = "/Home/Index";
},
error: function () {
$("#username").val("");
$("#password").val("");
alert("Wrong Username or Password!");
}
}); //end ajax call
It looks like you wrote this $.ajax call in the .click event of a submit button or in the .submit event of a form without canceling the default action by returning false from the callback or by calling preventDefault on the argument. Here's how your code should look like:
$('#id_of_your_form').submit(function(e) {
e.preventdefault(); // <-- That's what I am talking about and what you forgot
$.ajax({
type: "POST",
url: "Login/Login",
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: loginJson,
cache: true,
async: false,
complete: function (result) {
window.location.replace = "/Home/Index";
},
error: function () {
$("#username").val("");
$("#password").val("");
alert("Wrong Username or Password!");
}
}); //end ajax call
});
Also async: false,????? You know what this does, do you? That's not AJAX. That's a blocking synchronous call to your webserver during which the client browser would be frozen like during the Ice Age 2 ruining all user experience.
Try returning false at the end of your submit function
$('#id_of_your_form').submit(function(e) {
$.ajax({
type: "POST",
url: "Login/Login",
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: loginJson,
cache: true,
async: false,
complete: function (result) {
window.location = "/Home/Index";
},
error: function () {
$("#username").val("");
$("#password").val("");
alert("Wrong Username or Password!");
}
}); //end ajax call
return false; });
Another option would of course be to return the correct redirectlink from the controller instead of overriding it in the java script.