-1

I created a form and serialized its content to JSON. I'm kinda new to json. What i want to do is send the json to a url via POST but i dont know how to go about this. Here's my code

<h1>Register</h1> <form class = "myform" method="get"> Name:<br /> <input type="text" name="name" value="" /> <br /><br /> Phone Number:<br /> <input type="text" name="telephone" value="" /> <br /><br /> Location:<br /> <input type = "text" name = "location" value="" /> <br /><br /> Logo:<br /> <input type = "text" name = "logo" value="" /> <br /><br /> Website:<br /> <input type = "text" name = "website" value="" /> <br /><br /> Email:<br /> <input type = "text" name = "email" value="" /> <br /><br /> Category:<br /> <input type = "text" name = "category" value="" /> <br /><br /> Postal:<br /> <input type = "text" name = "postal" value="" /> <br /><br /> Description:<br /> <input type = "text" name = "description" value="" /> <br /><br /> GPS:<br /> <input type = "text" name = "gps" value="" /> <br /><br /> Tags:<br /> <input type = "text" name = "tags" value="" /> <br /><br /> Advert:<br /> <input type = "text" name = "advert" value="" /> <br /><br /> Facebook:<br /> <input type = "text" name = "facebook" value="" /> <br /><br /> Twitter:<br /> <input type = "text" name = "twitter" value="" /> <br /><br /> Google:<br /> <input type = "text" name = "google" value="" /> <br /><br /> <input type="submit" value="Submit" /> </form> <script src="jquery-1.11.1.min.js"></script> <script> var frm = $(document.myform); var data = JSON.stringify(frm.serializeArray()); console.log(data); </script> 

So how am I supposed to go about POSTing it to the url? (assuming the url is www.me.com)

3
  • 1
    You've got jQuery there, so use $.post()? Commented Aug 24, 2014 at 5:39
  • Did you atleast try a google search? Before posting? Commented Aug 24, 2014 at 5:53
  • You should try google before posting a question in stackoverflow, its gonna affect your reputation. ;) Commented Apr 2, 2015 at 23:44

1 Answer 1

1

Hi you can use ajax call to send json data

 jQuery.ajax( { url : getPostData.php, type: 'POST', dataType : "json", data: data, success:function(data) { alert(data); }, error: function() {alert(data); } } ); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.