The following loops through several rows of a table collecting data as it goes. For each iteration I say $jrow = JSON.stringify ($rowdata) and then $jschedule.push ($jrow);
After the stringify, a row looks like this... {"count":1,"bmaclass":"18-007","customer":"CST4070","course":"CRS0001","evdate":"","time":"","location":"0","stu1":"STU2336","stu2":"STU2623","stu3":"STU6808","instructor":"0","evaluator":"0"}
I would expect this to yield an array of strings which I then stringify and pass to PHP; however PHP sees nothing. I am at a loss as to how I can create this array and pass it to PHP. Seems like I've done it before but I'm having no luck this time.
var $jschedule = [];
$("table.tngdays tr").each (function ($index, $row){
$this = $(this);
$this.css("background","orange");
$time = $this.find('input.time');
$evtime = $time.val();
$time.css("background","pink");
$evdate = $this.find ("input.date").val(),
$evtime = $this.find ("input.time").val(),
$bmaclass = $("select.pendingClasses").val()
$location = $this.find (".loc").val()
$instructor = $this.find (".ins").val()
$evaluator = $this.find (".tce").val()
//console.log ($evdate, $evtime);
$rowdata = {
count : $count,
bmaclass : $bmaclass,
customer : $result.customer,
course : $result.course,
evdate : $evdate,
time : $evtime,
location : $location,
stu1 : $result.p1,
stu2 : $result.p2,
stu3 : $result.p3,
instructor : $instructor,
evaluator : $evaluator
}
$count ++;
$jrow = JSON.stringify($rowdata);
console.log ("Rowdata = " + typeof($jrow))
console.log ($jrow);
$jschedule.push ($jrow);
})
}) //each
$data = {
events:$jschedule
}
$data = JSON.stringify($data);
console.log ($data);
$.post ("/Training/ScheduleClass/pdo_saveClassEvents.php",{data:$data}, function ($result){
console.log ("Events = " + $result);
})
Thanks, DMD
The problem was a misplaced set of closing tags. Once I moved the post inside the proper tags, the problem disappeared.
Thanks all
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.