javascript - FormData Object Parsing Only One Input -


i have formdata object create using form's id. form has multiple input values. send formdata using xmlhttprequest().

however in request (which have debugged using google chrome's developer tool) can see in form data, when view "parsed" version sending first input value. when view source of formdata input values there.

my question

why when viewing parsed version of formdata can see 1 value whereas viewing source can see of them?

this may cause of other issues on server end not retrieving of parameters correctly.

edit - code

form

<form id='properties'>     <input type='text' name='name' value='previous'/>     <input type='text' name='occupation' value='unknown'/>     <input type='hidden' name='id' value='23'/> </form> 

javascript xmlhttprequest method

function sendrequest() {         var request = gethttprequest();     request.onreadystatechange=function() {         if (request.readystate==4 && request.status == 200) {             console.log("received response: "+request.response);         }     }     request.open("post","resort-service.php",true);     request.setrequestheader("content-type","application/x-www-form-urlencoded");     var form = new formdata(document.getelementbyid("properties"))     request.send(form); } 

google chrome developer tool - used debug xmlhttprequest after sent , response.

parsed data:

------webkitformboundary94v9bnbjffvklozw content-disposition: form-data; name:"name"  previous ------webkitformboundary94v9bnbjffvklozw content-disposition: form-data; name 

source data:

------webkitformboundary94v9bnbjffvklozw content-disposition: form-data; name="name"  previous ------webkitformboundary94v9bnbjffvklozw content-disposition: form-data; name="occupation"  unknown ------webkitformboundary94v9bnbjffvklozw content-disposition: form-data; name="id"  23 

after more hunting around on internet found solution.

the error line.

request.setrequestheader("content-type","application/x-www-form-urlencoded"); 

after removing line being transferred fine.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -