php - Form submit supposed to refresh only Div, but instead refreshes Page -


I have a PHP page called 'leguastas.fp'. This page allows the user to post a message / status update and is intended to refresh only this part of the intention; However, upon submission, the whole page is reloaded.

In the current implementation, I am simply printing all the $ _ POST variables in the div so that I can see what is going on. MsgText textarea is posted, however, it is only after the full page load I am just trying to get the div and the file is included to reload it.

  div id = "statusupdates" & gt; & Lt;? Include 'leaguestatus.php'; ? & Gt; & Lt; / Div & gt;  

leaguestatus.php

  & lt; Form ID = "Statusform" method = "Post" & gt; & Lt; Textera Name = MsgText Rows = 5 Columns = 40 & gt; & Lt; / Textarea & gt; & Lt; Br> & Lt; Input type = submit value = post id = uhsbutton> & Lt; / Form & gt; & Lt; BR & gt; & Lt; BR & gt; & Lt; Div id = 'formbox' & gt; By & lt;? Print "& lt; east & gt; POST variable: & lt; BR & gt;"; Print_r ($ _POST); Print "& lt; / pre & gt;"; $ MsgText = $ _POST ["MsgText"]; ? & Gt; & Lt; / Div & gt;  

I am going to the header in jQuery:

  $ (document) .ready (function () {$ ("# statusform") .submit (Function (e) {e.preventDefault (); formData = $ (this) .serialize (); above PURL = "leaguestatus.php"; submitFormSave (formData, PURL);}); SubmitFormSave function (formData, PURL) {$ .ajax ({url: PURL, type: 'POST', data: formData, success: function (feedback) {$ ("# formbox") HTML (feedback);}}) Success (function (..) {});}});  

Here are my covers:

html headers

  & lt; Link rel = "stylesheet" href = "css / jquery-ui.css" & gt; & Lt; Script src = "js / jquery-1.9.1.js" & gt; & Lt; / Script & gt; & Lt; Script src = "js / jquery-ui.js" & gt; & Lt; / Script & gt; & Lt; Script src = "http://malsup.github.com/jquery.form.js" & gt; & Lt; / Script & gt; Edit: To reflect the use of the response of the counter-response, the update code only works as expected on the first click page (no page refreshes), the whole page on the second page Click on the reload, we come back to normal on the third click.   

Use this code to submit ajax. This will work.

 $ ("# statusform") presented (function (e) {e.preventDefault (); on formData = $ (this) .serialize (); PURL = "leaguestatus.php "; SubmitFormSave (FormData, PURL);}); Function submitFormSave (formData, PURL) {$ .ajax ({url: PURL, type: 'POST', data: formData, success: function (feedback) {$ ("# formbox") HTML (feedback);}} ); }  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -