$(function(){ $('#submit').click(function(){ $('#container').append('<img src="img/loading.gif" alt="laduje" id="loading" />'); var name = $('#name').val(); var email = $('#email').val(); var comments = $('#comments').val(); $.ajax({ url: 'submit_to_db.php', type: 'POST', data: 'name=' + name + '&email=' + email + '&comments=' + comments, success: function(result){ $('#response').remove(); $('#container').append('<p id="response">' + result + '</p>'); $('#loading').fadeOut(500, function() { $(this).remove(); }); } }); return false; }); });
witam, mam taki kodzik, dziala mi to poprawnie, ale jest problem. po kliknieciu zamiast sie odswiezac to dodaje sie nowe pole.
czyli cos takiego:
Kod
1. jeden
dodaje dwa
i jest
Kod
1. jeden
2. dwa
1. jeden
2. dwa
1. jeden
dodaje trzy i jest
Kod
1. jeden
2. dwa
3. trzy
1. jeden
2.dwa
1. jeden
2. dwa
3. trzy
1. jeden
2.dwa
1. jeden
zamiast:
Kod
1. jeden
2. dwa
3. trzy
2. dwa
3. trzy
malo sie znam na AJAXie dlatego prosze powiedziec co trzeba zmienic