JavaScript HTTP Request (GET) Causes Refresh

Hello,

I'm having a little problem with the extended tab plugin I've been working on. I have a UI that allows TeamCity users to run custom build. I let the user pick things and click on "Run Build" button. The button is just a typical "button" that executes some HTTP request get from JavaScript.

So when I do...

$.get(myUrl, function(){//just some alert code here});

The UI refreshes unexpectedly. This is an AJAX type of operation, so I expected the UI to stay the same, but all the checkboxes and radio buttons are cleared. I am seeing "Clean all data under element buildConfigurationContainer" and then "Clean all data under element tabsContainer3". Obviously, this is clearing all my UIs.

The variable myUrl contains "/httpAuth/action.html?add2Queue=MyBuild&name=MyParam1&value=MyValue1&personal=true" by the way. So I'm just queuing a build from this extended tab.

The code that I expect to work is working just fine, but when the HTTP GET is done, somehow another HTTP GET request is thrown from another js file (-4270096801746814907.js or something like that) apparently reacting to the HTTP GET request I threw.

Is there any way to stop this unwanted refresh on my extended tab when I do HTTP GET on my JavaScript?

4 comments
Comment actions Permalink

Not sure where the problem is, need to reproduce it to better understand what happens.
But to simplify your code you can try using runBuild.tag custom tab to render run button. Or you can dig a bit deeper and use JS code from runBuild.js, example:
<button onclick="Event.stop(event); BS.RunBuild.runOnAgent(this, '<build configuration id>', { redirectTo: '', redirectToQueuedBuild: false, branchName: '<default>' });" title="">Run</button>

0
Comment actions Permalink

Hello,

Thank you for your reply.

Unfortunately, what you've suggested will not work for me because I need the UI (extended tab) to generate a parameter value in the first place.

The symptom I'm experiencing is as if some code is excuted reacting to my $.get(...) execution. The attached screen capture may be helpful?

5-21-2015 5-02-44 PM.png

Another thing to note is that when I see the HTTP log in the my Chrome browser, I get "WebSocket: Message received: 'events/c;b:bt1#2'" and then the extra and unwated call is made that clears my UI. Hopefully, someone can help me on this though I will continue to do my investigation on it.

0
Comment actions Permalink

Please try adding the following JS code to the page:
<script type="text/javascript">

 
$j(document).ready(function() {
 
  if (typeof BS == "undefined") return;
 
  BS.blockRefreshPermanently();

});
</script>

0
Comment actions Permalink

Yes, it worked! Thank you very much for your help.
This solution totally works for me, but I was just wondering if you can just mark the extended tab "non refreshable" on the Java code side? Just curious.

0

Please sign in to leave a comment.