Hello, I was told external .js files could be called with ajax. Anyone know how? Thank you very much!! Jen
Hi, All JS files included from a document are interpreted in the same environment so if the script containing your function is included then you can call the function directly. AJAX (XMLHttpRequest) is a technique used to call server-side scripts from the client scripting environment. Look up RPC for more information on that. Regards - P
look like wehn you want call a TEXT or HTML file, but with use of eval method! now you receive a text file result in ajax by this: HTTPRequest.ReponseText right? and now if you called a .js file, to run all functions and javascripts codes at this file you should use of this: "eval(HTTPRequest.ResponseText)" thats alone
Hi Jen, what is it you are trying to do? If you are trying to access data served from a different domain to the one that you are serving the page from then you should do some research about the script tag hack. Otherwise you will be dealing with cross domain security issues with your browser. Let me know if you would like more info as i've done quite a bit of research into this issue for a current project development.
Hey Bandito thats cool, sorry I was tied up for a bit. I need to know if I can call a js external script without putting my the external address into my source code. I am trying to protect a script it took me too long to write. Please let me know if your research taught you if this is possible. Thanks Jen
Well, if someone will try to take your script, he will . nobody can defend you script. even not ajax.
Some of us can try because we spend months and years writing complicated scripts. Please let some of us try if we need to. You don't have to agree with it. Thanks.
There is no real way to hide your script. You may try something like this but it is wired. It only makes it difficult to get your script. [I THINK] * Encrypt the script at server side before rendering * Using AJAX get the key used for encryption from server * Get the encrypted script from server * Use some javascript crypto functions [dojotoolkit.org] to decrypt the javascriptscript and use eval() as explained by earlier poster. But that still wont prevent someone from copying your script. You may want to generate different keys everytime ..but still it does not serve your purpose http://ashishware.com
There is simply no way to hide client side code since if there was it could not be parsed by the user agent. Same with HTML, CSS, etc. If you have a copyright notice in your script header, you are fully within your rights to pursue legal action if someone rips a decent-sized chunk out of it for their own gain.
You can obfuscate your code, look for example on google's btw, if you haven't any unique idea, nobody will crack your code, because it will be much easier to write similar themselves