Reputation: 147
I have a button :
<a href="#" id="buttonNew" class="buttonNew">{{ 'buttonNewText'|trans }}</a>
And an ajax action when i click on this button :
$(function(){
$("#buttonNew").click(function(e){
$.ajax({
type: "POST",
url: "{{ path('ajax_load_new_note_form') }}",
success: function(data) {
$('#homeLeft').html(data);
}
});
});
});
The first time i click on my button, a post request is sent, so it's OK. But when i click again no other request is sent. When i reload my page, the click send the request and not the next clicks.
What am i missing ?
Thank you by advance
Upvotes: 1
Views: 1648
Reputation: 1373
This should work:
$(function(){
$("#buttonNew").click(function(e){
$.ajax({
type: "POST",
url: "{{ path('ajax_load_new_note_form') }}",
success: function(data) {
$(this).html(data);
}
});
});
});
Upvotes: 0
Reputation: 2150
try
$(function(){
$("body").on('click','#buttonNew',function(e){
$.ajax({
type: "POST",
url: "{{ path('ajax_load_new_note_form') }}",
success: function(data) {
$('#homeLeft').html(data);
}
});
});
});
Upvotes: 2