[dx] Posted February 16, 2011 Share Posted February 16, 2011 Hi there,I have javascript function which works with ajax. It checks readyState, do innerHTML, etc.Works fine.Also have other function which calls that functions which works with ajax.Everything works fine. But now I have 1 select box, and 2 input boxes. When I change value at select box, it should paste data to those 2 inputs. But data are not same.So I call function like this:ajax(parameters, target1); // Target is ID where result will be shown at responseajax(other parameters, target2);Now when I calls it, first function sends parameters, then get aborted, and then other function works rest of job.Is there a way to avoid aborting somehow? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 16, 2011 Share Posted February 16, 2011 It sounds like they're both using the same connection or global XHR object. They should each be using their own. Link to comment Share on other sites More sharing options...
thescientist Posted February 16, 2011 Share Posted February 16, 2011 so basically you just need to create two separate objects to run each unique AJAX request. If you could post your code, we can confirm whether or not that is happening. Link to comment Share on other sites More sharing options...
[dx] Posted February 16, 2011 Author Share Posted February 16, 2011 Yes, that was, global definition of XHR.Before was ajax = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');function ajax_post() {} And like this works: function ajax_post() { ajax = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');} Thanks for clue. Link to comment Share on other sites More sharing options...
Synook Posted February 17, 2011 Share Posted February 17, 2011 That's still technically making it global - you need the var keyword. function ajax_post() { var ajax = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.