javascript - Problems posting data to a server using jQuery -


i'm student doing app jquerymobile , gonna compiled phonegap. want posting data server using jquery have problems loading .php file in server.

i have last version of jquery.

here put script post data form:

$(document).ready(function() {         var postdata = $('#registerform').serialize();          $('#registerform').submit(function() {             $.ajax({                 type: 'post',                 data: postdata,                 url: 'http://www.smartweb.cat/app/habana/user_register.php',                 success: function(data) {                     alert('usuari registrat correctament.');                 },                 error: function() {                     alert('hi ha algun problema amb el registre.');                 }             });             return false;         });     }); 

thanks lot , sorry english wrinting.

your post data empty. retrieve them directly when dom loaded , not when form submit. should move var postdata.

$(document).ready(function() {     //var postdata = $('#registerform').serialize();      $('#registerform').submit(function() {         var postdata = $('#registerform').serialize(); // here         $.ajax({             //...        });     }); }); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -