0

Iam working on adding an event planner to my Html form , and i cant figure out how to pass this data ("meetup","startEvent","break") from html to my Database . ive used jQuery to show the data on my browser console like this and it work

$(document).ready(function(){
$('#bang').on("click", function(){
    $("#editable > li").each(function(){

    $e=($(this).text());
    console.log($e);

but i cant get it to send to another page

$(document).ready(function(){
$('#bang').on("click", function(){
    $("#editable > li").each(function(){

    $e=($(this).text());
    console.log($e);



    $("#submit").click(function(){
        $.ajax(
            {
         url: "test.php",
         type: "POST",
         data: {$e},
        success: function (result) {
        alert('success');
1
  • 1
    data: { value: $e }, Commented Mar 26, 2018 at 16:21

1 Answer 1

1

jQuery('#bang').on("click", function () {

  var data = [];

  jQuery("#editable > li").each(function () {
    data.push(jQuery(this).text());
  });

	console.log(data);

	jQuery.post('test.php', data).done(function () {
    console.log('Done!');
  }).fail(function () {
    console.log('Nopo!');
  });

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul id="editable">
  <li>test</li>
  <li>me</li>
  <li>out</li>
</ul>

<button id="bang">bang!</button>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.