@state = State.where("country_id = :c_id",{:c_id => params[:country_id]})
respond_to do |format|
format.html
end
end
previously the it was format.js when nothing on the page was changing dynamically but when i make it format.html, the state drop down changes but i get all the unnecessary thing like the the entire html page.
HEy cool… Thanks a lot…it worked however with state drop down i also iam getting a lot of other un necessary html… The html is what i have written in application.html.erb for templating purpose… Is this the wrong way to write static html code in application.html.erb… Thanks a lot…
HEy cool… Thanks a lot…it worked however with state drop down i also iam getting a lot of other un necessary html… The html is what i have written in application.html.erb for templating purpose… Is this the wrong way to write static html code in application.html.erb… Thanks a lot…
You need to tell your view not render the layout. You should read the Rails guide to rendering and layouts. I’ll let you figure it out from there:
Have the index method of the StatesController respond to the .json request and render the states back as a JSON array. Let the browser and create the tags using Javascript.
IMHO that way is quicker, slicker and more maintainable.
Also, in your current form, you could replace your $.ajax method with:
Hey Guys… All of You… Thanks alot… i have achieved it…i was struglling on it from 2 3 days…and without all of your help i wouldnt have successeded… RUBY ON RAILS ROCK…thanks
The first problem here is that you have asked a very general question
which could mean a number of different things.
Do you mean you want to get these from your own website or are you
looking for another server somewhere that you can get them from? If
from your own website do you already have the data in the database?
Please try to ask more specific questions in future. Otherwise we
spend a lot of time just trying to find out what you are trying to do.