Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

How to execute a external Javascript file from html page. I need to send input to .js file And I also need to get output from external .js file.

I am thinking like building a input.xml file with my inputs as nodes in it. I will execute the external .js file by sending my input.xml file. My external .js file will parse my input.xml and perform the function using my inputs. External .js will build the Output.xml file with results as a nodes in it. My html page needs to parse the Output.xml and display the results in the html page.

I can do all the other stuff, but I couldn't figure how to execute the external .js file by sending my input.xml and read Output.xml from .js file.

Any ideas for this kind of design??

share|improve this question
1  
<script src="/path/to/external.js">? –  Pekka 웃 17 mins ago
 
I need to execute it by sending my input.xml and read the output.xml from the external.js file. –  Powered 12 mins ago

1 Answer

path/to/file.js:

function externalfunction(input) {
    //stuff
};

index.html:

<script src="path/to/file.js"></script>
<script>
somevar = externalfunction(someothervar);
</script>
share|improve this answer
 
An explanation would be nice... –  Bojangles 13 mins ago
 
I need to execute it by sending my input.xml and read the output.xml from the external.js file. –  Powered 12 mins ago
 
@Powered Edited now. Ok... –  Dude 9 mins ago
 
@Dude My question is actually how execute the external.js file from HTML page and send my inputs to that .js file as input.xml and read the output.xml from .js file and display in my HTML page. Something like Execute( external.js, input.xml) and read the output from it like Execute.output or something. Sorry about my English and vocabulary. –  Powered 5 mins ago
 
@Powered Edited. –  Dude 4 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.