id=my_form
, а потом document.getElementById('my_form').submit()
<input type=file id=my_files name=files multiple>
и formData.append("files", document.getElementById('my_files').value);
. И вывод лучше через console.dir(xhr)
. else:
$errors['success']="Пользователь радостно создан. Аллилуя!";
<?php
if (!empty($_POST['value'])) {
$con = mysqli_connect('localhost','root','','test') or die(mysqli_connect_error());
//echo "Выбран option с значением - ".$_POST['value'];
$sqls = "SELECT * FROM `student` WHERE `fid`='".mysqli_real_escape_string($con, $_POST['value'])."'";
$res = mysqli_query($con, $sqls) or die(mysqli_error($con));
?>
<div class="info">
<?php
if(!empty($res) AND $res->num_rows) {
$row=$res->fetch_assoc();
echo "<br> Студент:".' '. $row["sname"].' '. $row["birthday"];
}
mysqli_close($con);
?>
</div>
<?php
}
if($_POST['value'] == '0'){
?>
<style type="text/css">
#res{
display: none;
}
</style>
<?php
}
if(!empty($_POST['name'])) {
$birthday='1989';
$name =$_POST['sname'];
$fid = $_POST['value'];
$con = new mysqli('localhost','ijdbuser','a9b8e7q6555','workhome') or die(mysqli_connect_error());
mysqli_query($con, "INSERT INTO student (sname,birthday,fid) VALUES('".mysqli_real_escape_string($con, $sname)."','".mysqli_real_escape_string($con, $birthday)."','".mysqli_real_escape_string($con, $fid)."')") or die(mysqi_error($con));
mysqli_close($con);
}
?>
<html><title>Click-n-Win!</title>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
<div style='width:200px; height:250px; border:1px solid black;'>
<div id=heading style='position:relative; width:100px; height:50px; border:1px solid red;'>Click</div>
</div>
<script>
var leftOffset = 0, topOffset = 0;
var moveHeading = function () {
if (leftOffset < $("#heading").parent().innerWidth() - $("#heading").outerWidth() && topOffset <=0) leftOffset += clicks * 3;
if (leftOffset >= $("#heading").parent().innerWidth() - $("#heading").outerWidth() && topOffset < $("#heading").parent().innerHeight() - $("#heading").outerHeight())
topOffset += clicks * 3;
if (leftOffset > 0 && topOffset >= $("#heading").parent().innerHeight() - $("#heading").outerHeight()) leftOffset -= clicks * 3;
if (leftOffset <= 0 && topOffset > 0) topOffset -= clicks * 3;
$("#heading").offset({ left: $("#heading").parent().offset().left + leftOffset, top: $("#heading").parent().offset().top + topOffset});
};
var clicks = 0, intervalId;
$("#heading").click(function () {
clicks++;
if (clicks == 1) intervalId = setInterval(moveHeading, 5);
if (clicks < 10) $("#heading").text("You clicked "+clicks);
if (clicks == 10) { clearInterval(intervalId); $("#heading").text("Congratulations! You won!"); }
});
</script>
</body>
</html>
console.log(data);
, а console.dir(data);
, и посмотрите на структуру данных. Скорее всего там будет одна строка. А должны быть отдельные переменные "fail" и "errors". Если их нет - то и if (data.fail) {
работать не будет, потому что data не распарсилась как JSON. А в JQuery ведь есть функция парсинга JSON, да?