megetron Posted March 12, 2012 Share Posted March 12, 2012 Hi, I am trying tocreate a simple form that do submit (form for mobiles). But the code does not do a submit (debug it and the success function is not executed on submit). here is the code: <form id="ContactForm"> <p class="mandatory"> </p> <div data-role="fieldcontain" class="text-field"> <label for="LAST_NAME">שם מלא:</label> <input type="text" name="LAST_NAME" value="" placeholder="" class="required" id="LAST_NAME" /> </div> <div data-role="fieldcontain" class="text-field"> <label for="mobilephone">טלפון:</label> <input type="number" name="PHONE_MOBILE" value="" placeholder="" id="PHONE_MOBILE" /class="required" > </div> <div class="send"> <a href="javascript:;" data-role="button" data-theme="a" data-iconpos="right" id="send">הרשמה!</a> <input type="submit" name="submit" value="Submit" id="send1"/> </div> <input type="hidden" name="LEAD_SOURCE" value="MOBILE"> <input type="hidden" name="ASSIGNED_USER_ID" value="fe1032ed-fbe7-44b7-b724-8b9dc7e6e01b"> <input type="hidden" name="MODIFIED_USER_ID" value=""> </form> and the function: $('.returnTopAction').live('click', function() { $('html, body').animate({scrollTop: '0'}, 700); }); $('#gallery-page').live('pageshow', function () { $myPhotoSwipe = $(".gallery a").photoSwipe({ enableMouseWheel: false , enableKeyboard: false });}); $('#send').live("click", function() { var url = 'http://crm.karusela.net/Leads/WebToLeadCapture.aspx'; var error = 0; var $contactpage = $(this).closest('.ui-page'); var $contactform = $(this).closest('.contact-form'); $('.required', $contactform).each(function(i) { if($(this).val() === '') { error++; } }) // each //alert($contactpage); if(error > 0) { alert('ERR'); } else { //submit the form $.ajax({type:'GET', url: url, data:$('#ContactForm').serialize(), success : function(data) { alert("THIS FUNC DOES NOT EXECUTED"); if(data == 'success') { // show thank you $contactpage.find('.contact-thankyou').show(); $contactpage.find('.contact-form').hide(); } else { alert('ERR.'); } } }); } return false; }); Quote Link to comment https://forums.phpfreaks.com/topic/258781-jquery-help/ Share on other sites More sharing options...
sunfighter Posted March 13, 2012 Share Posted March 13, 2012 Your form uses a SUBMIT button. When you do that the instruction for the submit is contained in the <form> tag. Normally it would look like this: <form id="ContactForm" action="url of where the form is being sent" method="get or post"> You are missing the action and the method so it calls it's self and you have no php to handle it. If you want the jquery to handle it change the button type to button and add an onclick. Or have the jquery look for a click event. Quote Link to comment https://forums.phpfreaks.com/topic/258781-jquery-help/#findComment-1326947 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.