Hello,
I'm trying to upgrade from Jira 4.2.3 to Jira 5.0. I have several javascript snippets (that I have placed in the descriptions for certain fields) that make a simple AJAX call to a server-side php file that then grabs some information from the database and sends it back. These all work fine in 4.2.3. However in 5.0 I am unable to make even the simplest AJAX call.
The closest I've come so far: I'm testing with an AJAX call that gives me an alert box of the responseText. The alert box is blank but in Firebug I can see the response and the status says "301 Permanently Moved". I'm using the code below to make the AJAX call:
<script type="text/javascript"> if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest(); else if (window.ActiveXObject) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.open("GET",'/scripts/getgroups.php',true); xmlhttp.send(null); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) alert( xmlhttp.responseText ); } </script>
The only thing I've found in the documentation is this which, if I'm reading it correctly, says that AJAX calls are no longer supported out of the fear that it might not load in time? If this is true is there a way to override this (something like, "edit this file to disable that security feature")? I saw that it was recommended to use .live() or .delegate() but I still have to make an AJAX call. I've also tried the jQuery version (code below) but it's the same problem.
<script type="text/javascript"> AJS.$.ajax({ url: "/scripts/getgroups.php", type: "GET", success: function(msg){ alert(msg); } }); </script>
Hopefully I'm missing something simple here. Thank you for any help you can provide,
Brad
Community moderators have prevented the ability to post new answers.
There's nothing in jira that could stop you running ajax requests as far as I know.
I would say the problem is going to be something simple... is the/scripts/getgroups.php really there, in relation to the url you are accessing jira from?
You probably are actually getting the 301.
> The only thing I've found in the documentation is this which, if I'm reading it correctly, says that AJAX calls are no longer supported out of the fear that it might not load in time?
That's not my reading of it... AFAIK it says you can't load javascript from custom field classes using the resourcemanager, because the page has already loaded.
Hi Jamie,
Thanks for the quick reply. I know it's in the right place because I can see the response I'm expecting in Firebug. It just doesn't let my javascript access it or view it (or something). I've also tried the full URL path with the same outcome.
I'm glad this isn't unsupported (I assume you were able to do it successfully in Jira 5.0).
Thanks again. I guess I'll just have to stare at it a little longer. :)
Brad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi... it's all on the same host, same port right? Ie this is not browser anti-XSS stuff causing the problems? I recommend you install Fiddler... this will let you see all the requests and responsers, with headers, content, etc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, finally got it. It was a combination of using https (instead of http) and setting up my apache config file correctly (I had it pointing to scripts folder for http but not https).
Thank you for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.