gpt4 book ai didi

javascript - jQuery JIRA Post 无法在 IE/FF 中工作

转载 作者:行者123 更新时间:2023-11-28 06:51:04 27 4
gpt4 key购买 nike

我正在尝试将数据发布到 JIRA,但它似乎只能在 Chrome 中使用。不适用于 IE/FF。请帮忙。我认为这与ajax调用设置有关。不确定我需要什么才能让它发挥作用。

       $('#new_request > footer > input').bind('click', function(e) {

var subjects = $("#request_subject").val();
var descriptions = $("#request_description").val();
var attachments = $(".upload-link").attr('href');
var cust1 = $("#request_custom_fields_27736417").val();
var cust2 = $("#request_custom_fields_27745068").val();
var cust3 = $("#request_custom_fields_27736427").val();
var cust4 = $("#request_custom_fields_27745078").val();
var cust5 = $("#request_custom_fields_27736437").val();
var cust6 = $("#request_custom_fields_27638038").val();
var cust7 = $("#request_custom_fields_27638118").val();
var cust8 = $("#request_custom_fields_27632077").val();
var cust9 = $("#request_custom_fields_27632087").val();

if (subjects !== null || descriptions !== null){

function CreateJIRATicket(summary,description, custom1,custom2,custom3,custom4,custom5,custom6,custom7,custom8,custom9,custom10 ) {

var JIRAusername = "YouruserName";
var JIRApassword = "YourPassword";



var jsondata = {"fields":
{ "project":{ "key": "ZDI"},
"summary": summary,
"description":description,
"issuetype": {"name": "Story" },
"customfield_11200" : custom1,
"customfield_11201" : custom2,
"customfield_11202" : custom3,
"customfield_11203" : custom4,
"customfield_11204" : custom5,
"customfield_11205" : custom6,
"customfield_11206" : custom7,
"customfield_11207" : custom8,
"customfield_11208" : custom9,
"customfield_11209" : custom10
}
};

$.ajax({
type: "POST",

crossDomain: true,
contentType:"application/json; charset=utf-8",
dataType: "json",
username: JIRAusername,
password: JIRApassword,
data: JSON.stringify(jsondata),
url: "https://jira.yourdomain.com/rest/api/2/issue",
xhrFields: {
"withCredentials": true
},

success: function (ticket){
console.log('Page saved!', ticket);
},
error : function(xhr, errorText){
console.log('Error '+ xhr.responseText);
}



})//end ajax post JIRA

}




}






CreateJIRATicket(subjects, descriptions, cust1, cust2, cust3, cust4, cust5, cust6, cust7, cust8, cust9, attachments);



});



}

最佳答案

代码重组:函数CreateJIRATicket取出IF结构,并将contentType更改为使用默认值(为什么是“application/json”?)。试试这个:

function CreateJIRATicket(summary,description, custom1,custom2,custom3,custom4,custom5,custom6,custom7,custom8,custom9,custom10) {
var JIRAusername = "YouruserName";
var JIRApassword = "YourPassword";
var jsondata = {"fields":
{ "project":{ "key": "ZDI"},
"summary": summary,
"description":description,
"issuetype": {"name": "Story" },
"customfield_11200" : custom1,
"customfield_11201" : custom2,
"customfield_11202" : custom3,
"customfield_11203" : custom4,
"customfield_11204" : custom5,
"customfield_11205" : custom6,
"customfield_11206" : custom7,
"customfield_11207" : custom8,
"customfield_11208" : custom9,
"customfield_11209" : custom10}
};
$.ajax({
type: "POST",
crossDomain: true,
contentType:"application/x-www-form-urlencoded; charset=UTF-8",
dataType: "json",
username: JIRAusername,
password: JIRApassword,
data: JSON.stringify(jsondata),
url: "https://jira.yourdomain.com/rest/api/2/issue",
xhrFields: {"withCredentials": true},
success: function (ticket){console.log('Page saved!', ticket);},
error : function(xhr, errorText){console.log('Error '+ xhr.responseText);}
})//end ajax post JIRA
}

$('#new_request > footer > input').bind('click', function(e) {
var subjects = $("#request_subject").val();
var descriptions = $("#request_description").val();

if (subjects !== null || descriptions !== null){
var attachments = $(".upload-link").attr('href');
var cust1 = $("#request_custom_fields_27736417").val();
var cust2 = $("#request_custom_fields_27745068").val();
var cust3 = $("#request_custom_fields_27736427").val();
var cust4 = $("#request_custom_fields_27745078").val();
var cust5 = $("#request_custom_fields_27736437").val();
var cust6 = $("#request_custom_fields_27638038").val();
var cust7 = $("#request_custom_fields_27638118").val();
var cust8 = $("#request_custom_fields_27632077").val();
var cust9 = $("#request_custom_fields_27632087").val();
CreateJIRATicket(subjects, descriptions, cust1, cust2, cust3, cust4, cust5, cust6, cust7, cust8, cust9, attachments);
}
});

关于javascript - jQuery JIRA Post 无法在 IE/FF 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32958688/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com