Conditional Ajax request.

Hi Everybody!

I have an ajax request, it will replace a div content with partial file
like below.

render :update do |page|
  page.replace_html :track_info, :partial =>"shared/trackinfo"
end

Here i want to check whether the div exists or not, before replacing its
content. Like below

if $('track_info')
$('track_info').innerHTML="playlist info partial content"
else
#do nothing.

Can anyone suggest me conditional ajax statement for the above
condition.

Thanks in advance.
T.Veeraa

Maybe you can try the below one:

page.select("#track_info").each do |value|
page.replace_html “track_info”, :partial => “shared/trackinfo”
end