简体   繁体   English

用Jquery和PHP保存的数组

[英]Arrays saved with Jquery & PHP

Here I am saving the following array to a text file, it is dynamic and can have one value or 1000 values, how is it possible for me to read this back into html? 在这里,我将以下数组保存到文本文件中,该数组是动态的,可以有一个值或1000个值,我如何将其读回html?

questionbanknames This Is The Hard Onequestion-1 1?questiontype-1 manualanswer-1a answer-1b answer-1c answer-1d question-2 2?questiontype-2 multianswer-2a ans1answer-2b ans2answer-2c ans3answer-2d ans4





$('#maincontent').on("click", "#addquestion", function(){
  questionnumber++;

  var getquestiontype = $('input[name=questiontype]');
  questiontype = getquestiontype.filter(':checked').val();
  question = $('#question').val();
  answer1 = $('#ans1').val();
  answer2 = $('#ans2').val();
  answer3 = $('#ans3').val();
  answer4 = $('#ans4').val();

  questiondata = '<div><input type="text" id="question-'+questionnumber+'" name="question-'+questionnumber+'" value="'+question+'">\
  <input type="text" id="questiontype-'+questionnumber+'" name="questiontype-'+questionnumber+'" value="'+questiontype+'">\
  <input type="hidden" id="answer-'+questionnumber+'a" name="answer-'+questionnumber+'a" value="'+answer1+'">\
  <input type="hidden" id="answer-'+questionnumber+'b" name="answer-'+questionnumber+'b" value="'+answer2+'">\
  <input type="hidden" id="answer-'+questionnumber+'c" name="answer-'+questionnumber+'c" value="'+answer3+'">\
  <input type="hidden" id="answer-'+questionnumber+'d" name="answer-'+questionnumber+'d" value="'+answer4+'"></div>';

  $('#addquestions').append(questiondata);

});

$('#maincontent').on("click", "#writedata", function(){ //submitting questions
    $.ajax( {
      type: "POST",
      url: 'admin/setup/getdata.php',
      data: $("form").serialize(),
      success: function( response ) {
        alert(response);
      }
    });
    return false;
  } );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM