Want to set 'src' of script to my IP.

Posted by Ozaki on Stack Overflow See other posts from Stack Overflow or by Ozaki
Published on 2010-05-17T07:02:46Z Indexed on 2010/05/17 7:10 UTC
Read the original article Hit count: 188

Filed under:
|
|

I have a script that links to the server I am hosting (IP can change) usually I would just use for links:

 var url ='http://' + window.location.hostname + 'end of url';

But in this case it isnt appearing to be so easy.

I have tried: (1)

$('#scriptid').attr('src', url);

as well as: (2)

var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = url;
$("#insert").append( script );

Now case (2) works loads the script runs the script. But when at the end of my script it hits the 'write data' it decides to replace the entire page with just the data.

Any idea on how I can do this?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery