views:

4263

answers:

3

Hi,

I tried to concatenate a string to a div with its value but I can't please help. Here is my little codes

var server = 'server name: '
$('#div').load('myservername.aspx');

I like to display at div id is

server name: myserver

Thanks.

+3  A: 

Tweaking what you have

$('#div').load('myservername.aspx');
$('#div').prepend('Server Name:')

Could also do

$.get("myservername.aspx", function(data){

$('#div').html('Server name: ' + data)

});
Ryu
Ryu,I tried your code but I got nothing return.:-(
Try the newly edited version.
ceejayoz
I tried it but it gave me just the server name.
Ryu, Thanks I got it with your latest codes. Ignore my previous answer. :-)
How about clicking the checkmark to indicate this is the accepted answer.
Ryu
A: 

jQuery manipulation docs have these little codes to append

$("p").append("<strong>Hello</strong>");
slf
A: 

I'm assuming that you have an html with the following html code

<div id="some_id">
</div>

and you want to load the div with server name: myserver (?).

If so, i think you can use

$('#some_id').text("server name: myserver");
devpl
I think you're missing the point that `myservername.aspx` seems to return the name of a server. Hard coding it to 'myserver' is easy, but not what the OP wants to do.
ceejayoz
to clarify I like to concatenatevar server = 'server name: '$('#div').load('myservername.aspx');server + ' ' + $('#div').load('myservername.aspx');
I see what you mean. Yeah I can do that, but I like to have it dynamic change. :-)