jquery ajax submit form to php -
I have just started trying to learn jquery but I need some help.
I have found a form that I am trying to submit, it should be simple, but some are messing me up I'm using Chrome's console to see what's going on , And functions.php is not requested. Apart from this, instead of a post request, a request is appearing in the request console.
I have included jquery in the file's head.
Cold someone tells me what I'm doing is wrong here? I have tried many other examples which I have successfully successful on the forum.
html:
& lt; Form name = "myPage_form" id = "myPage_form" & gt; & Lt; Enter "auto integer" on the input id = "myPage_location" type = "text" size = "50" placeholder = "" location = "server" />. & Lt; Input type = "text" id = "myPage" "name =" myPAGE_city "/> & Lt; Input type = "text" id = "myPage mixed" name = "myPageboundLat" /> & Lt; Input type = "text" id = "myPage_citylng" name = "myPage_citylng" /> & Lt; Input type = "text" id = "myPage_type" name = "myPage_type" value = "selected" /> & Lt; Input type = "submit" value = "submit" /> & Lt; / Form & gt; & Lt; Div id = "response-div" & gt; Place is: & lt; / Div & gt;
jQuery:
submitted (function () {{myPage_city = document.getElementById ('myPage_city'); myPage_cityLat = document.getElementById ('myPage'Lat'); myPage_cityLng = document GetElementById ('myPage_cityLng'); myPage_type = document.getElementById ('myPage_type'); $ .ajax ({url: 'functions.php', data: ({myPage_type: myPage_type, myPorge_city: myPage_city, myPage_cityLat: myPage_cityLat, myPage_citylng: myPage_cityLng }), Type: 'post', success: function (data) {$ ('# reaction-div') enclosed (data);}});}});
If you are using jQuery, then you document.get * Why are using the
function to try this:.
$ ('# myPage_form') submitted (function (e) {{e.preventDefault (); //
Or, simply use the .serializeArray
function Do:
$ ('# myPage_form'). Submit (function (E) {{e.preventDefault (); // & lt; - Vir data to prevent form submission = $ (this). SerializeArray (); $ .ajax ({url: 'functions.php', Data: Type: 'Post', Success: Function (data) {$ ('# response-div'). Attachment (data);}}}}}});
Comments
Post a Comment