简体   繁体   中英

Trying to submit a form after loading it via ajax

I'm loading a from a server using ajax, but when I try to submit it, it is never submitted.. Here is the code:

$(document).ready(function() {

function successHandler (result) {
}

function errorHandler (error) {
}

$.ajax({url: "http://www.****.com/new",
  dataType: 'html',
  beforeSend: function() {
  },
  complete: function() {
  },
  success: function (result) {
  $('#app-status-ul').hide();

  ajax.parseJSONP(result);
  },
  error: function (request,error) {
  alert('Network error has occurred please try again!');
  }
});

var ajax = {
parseJSONP:function(data){

$('#movie-data').append(data);

$('#movie-data').listview('refresh');
var newTheme = 'b';
}
}

//HERE I TRY TO SUBMIT THE LOADED FORM
$("form").on('submit', function() {
  alert( "Form submitted" );
});

});

As you can guess I expect an alert('Form submited') after submit it.

您必须使用Jquery函数Submit submit()http://api.jquery.com/submit/ ):

$("form").submit();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM