You cannot do JSON POST directly from forms. The only way is via Ajax requests. So you need to bind the click event for the "Ok" button to a JavaScript function that calls the server side with an Ajax call. On Thu, Jan 24, 2013 at 7:41 AM, Kevin Jenkins <gameprogrammer@xxxxxxxxxx>wrote: > Sorry for not being clear. I'm OK on the server side because I'm writing > it in Java and am using json-lib to read the body of the post. But for > testing I want to write a webpage that can do a POST from an HTML form > > <form> > First name: <input type="text" name="firstname"><br> > Last name: <input type="text" name="lastname"><br> > <input type="submit" value="Submit"> > </form> > > With that code the body is not in JSON format. I was wondering if there > was a simple way to make any form put the body in JSON format. Or lacking > that, at least how to hand-craft it so that it is. I found some javascript > code online but it didn't work, that is what I was alluding to. > > > > On Wed, Jan 23, 2013 at 9:51 PM, Michael Croghan > <mcroghan@xxxxxxxxxxxxxx>wrote: > >> Didn't think about server side. :) >> >> One way half-a-dozen ways depending on what specifically you're trying to >> do. >> >> >> On Wed, Jan 23, 2013 at 9:39 PM, Alan Wolfe <alan.wolfe@xxxxxxxxx> wrote: >> >>> btw... a sly trick i use sometimes when i have http questions of this >>> sort is i'll go ask on the libcurl mailing list (shh) >>> >>> People tend not to consider it off topic, and they will actually think >>> that you are trying to achieve something with libcurl (mostly i am, >>> but not always) - and there's a lot of super knowledgeable people >>> there with regards to this sort of thing. >>> >>> On Wed, Jan 23, 2013 at 9:36 PM, Alan Wolfe <alan.wolfe@xxxxxxxxx> >>> wrote: >>> > i think it partly depends on the server understanding your intentions >>> > (ie apache vs IIS vs WCF even, are different if i recall correctly), >>> > but the official content-type is "application/json" according to the >>> > RFCs >>> > >>> > http://tools.ietf.org/html/rfc4627 >>> > >>> > doesn't do a lick of good if that doesn't work for you though (: >>> > >>> > On Wed, Jan 23, 2013 at 9:19 PM, Kevin Jenkins >>> > <gameprogrammer@xxxxxxxxxx> wrote: >>> >> Does anyone know how to do an HTML form POST using JSON format? I >>> searched >>> >> online but couldn't find any clear explanations or source-code that >>> actually >>> >> worked. >>> >>> --------------------- >>> To unsubscribe go to http://gameprogrammer.com/mailinglist.html >>> >>> >>> >> >