$.ajax({
type: "GET",
dataType: 'script',
url: '/admin/my_page/'+mypage_id+'/pages/show_page',
style : "inherit",
dataType: 'script',
data: "submitcheckdata="+mypage_id,
complete: function() {
}
});
THere are two problems :
- Lhow do i fetch variables from my pages controller and pass to page.js file?
if i have the id, - then how do i generate dynamic url using ajax.?
You will have to include your JS within your HTML ( I will use HAML in my example )
Sometimes I feel like this gets kind of ugly putting HTML and Javscript together. It’s like mixing your dessert with your dinner. So I include it as a separate partial especially if you have a lot Rails dependent JS.
Another technique I employed once before was I sent out an initial AJAX request that would retrieve what dynamic content I would need to produce a second AJAX request that would be effectually, what you have as an example.