Jump to content

Call one func twice at the same time


[dx]

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...