I am having a problem with some jquery dialog code. The window opens ok the first time and if I submit the form, it returns the message in the div. However, if after closing the dialog, I open it again, it still retains the message and has not cleared. Also, when I press the submit button, it will open the php page twice. It seems to do this on each time I open the dialog. If I close and open the dialog again it will open the php page 3 times. Where am I going wrong with this?
// feedback form
$(document).ready(function(){
function feedbacknew() {
// jquery-ui confirm dialog box
$("#form").dialog({
autoOpen: false,
resizable: false,
modal: true,
title: 'Submit a feedback request',
width: 440,
height: 470
/*buttons: {
'Remove': function () { // remove what you want to remove
// do something here
alert("this is a test alert!");
$(this).dialog('close');
$("#flex1").flexReload();
},
Cancel: function () {
$(this).dialog('close');
}
}*/
});
});
$('#submit').click(function () {
var name = $('.uname').val();
var data = 'uname=' + name;
$.ajax({
type: "POST",
url: "feedback.php",
data: data,
success: function (data) {
$('#message').html(data);
$("#flex1").flexReload();
},
error:function (xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);
}
});
return false;
});
$("#form").dialog('open');
}