form plugin - mulsup problem
Have a problem,when click on update button,an text is edited and added againg,here is the code :
- <form action="moj.php" id="my-form" method="get">
- <textarea class="txt-area-class" id="txt-area-id" name="txt-area-name" cols="40" rows="1"></textarea>
- <input type="reset" value="Cancel" id="btnReset" />
- <input type="submit" value="Add text" id="btnAdd" />
- <input type="submit" value="Edit text" id="btnEdit" />
- </form>
- .
- .
- .
- var form_add = {
- data: {'my_var':'1'},
- dataType: 'json',
- cache:false,
- beforeSubmit : function(formData, jqForm, options,responseText,msg){
- zahtevZaObradu(formData, jqForm, options,responseText,msg='Dodan je text');
- },
- url: 'moj.php',
- success: obradjenZahtev,
- resetForm: true
- };
- var form_edit = {
- data: {'my_var':'2'},
- dataType: 'json',
- cache:false,
- beforeSubmit : function(formData, jqForm, options,responseText,msg){
- zahtevZaObradu(formData, jqForm, options,responseText,msg='Izmenjen je text');
- },
- url: 'moj.php',
- success: obradjenZahtev,
- resetForm: true
- };
- .
- .
- .
- function zahtevZaObradu(formData, jqForm, options,responseText,msg) {
- alert($.param(formData));
- return true;
- }
- .
- .
- .
- $("#btnAdd").click(function(){
- $("#my-form").ajaxForm(form_add);
- });
- $("#btnEdit").click(function(){
- $("#my-form").ajaxForm(form_edit);
- });
I just want to edit text,not to add it.Tnx in advance