Javascript jQuery JIRA Post不在IE/FF中工作
我试图将数据发布到JIRA,它似乎只在Chrome中起作用。在IE/FF中不起作用。请帮忙。我认为这与ajax调用设置有关。我不知道我需要什么来让它工作Javascript jQuery JIRA Post不在IE/FF中工作,javascript,jquery,ajax,jira,jira-rest-api,Javascript,Jquery,Ajax,Jira,Jira Rest Api,我试图将数据发布到JIRA,它似乎只在Chrome中起作用。在IE/FF中不起作用。请帮忙。我认为这与ajax调用设置有关。我不知道我需要什么来让它工作 $('new#u request>footer>input').bind('click',函数(e){ var subject=$(“#请求_subject”).val(); var descriptions=$(“#请求_描述”).val(); var attachments=$(“.upload link”).attr('href');
$('new#u request>footer>input').bind('click',函数(e){
var subject=$(“#请求_subject”).val();
var descriptions=$(“#请求_描述”).val();
var attachments=$(“.upload link”).attr('href');
var cust1=$(“#请求_自定义_字段_27736417”).val();
var cust2=$(“#请求_自定义_字段_27745068”).val();
var cust3=$(“#请求_自定义_字段_27736427”).val();
var cust4=$(“#请求_自定义_字段_27745078”).val();
var cust5=$(“#请求_自定义_字段_27736437”).val();
var cust6=$(“#请求_自定义_字段_27638038”).val();
var cust7=$(“#请求_自定义_字段_27638118”).val();
var cust8=$(“#请求_自定义_字段_27632077”).val();
var cust9=$(“#请求_自定义_字段_27632087”).val();
if(主题!==null | |描述!==null){
函数CreateJIRATicket(摘要、描述、custom1、custom2、custom3、custom4、custom5、custom6、custom7、custom8、custom9、custom10){
var JIRAusername=“YouruserName”;
var JIRApassword=“您的密码”;
var jsondata={“字段”:
{“项目”:{“关键”:“ZDI”},
“摘要”:摘要,
“描述”:描述,
“发行类型”:{“名称”:“故事”},
“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({
类型:“POST”,
跨域:是的,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
用户名:JIRAusername,
密码:JIRApassword,
数据:JSON.stringify(jsondata),
url:“https://jira.yourdomain.com/rest/api/2/issue",
xhrFields:{
“withCredentials”:true
},
成功:功能(票){
console.log('Page saved!',ticket);
},
错误:函数(xhr,errorText){
console.log('Error'+xhr.responseText);
}
})//结束后JIRA
}
}
CreateJIRATicket(主题、描述、cust1、cust2、cust3、cust4、cust5、cust6、cust7、cust8、cust9、附件);
});
}
代码重新组织:函数CreateJIRATicket去掉IF结构,并更改contentType以使用默认值(为什么是“应用程序/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);
}
});
代码重新组织:函数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);
}
});
你犯了什么错误?那个跨域交换机看起来可疑。你有什么错误?那个跨域交换机看起来可疑。