$json = file_get_contents('php://input');
$data = json_decode($json);
print_r($data);

<script>
function myFunction() {
var query = '?';
var str = $("form").serialize();
$("#results").text(query += str);
var x = $("#results").text();
return x;
}
$( "input[type='sel'], input[type='text']").on( "click", myFunction);
$( "select" ).on( "change", myFunction);
//window.alert(myFunction());
//query += '&' + value + '=' + value +'.value';
var jsonString = JSON.stringify(myFunction());
console.log(jsonString);
$.ajax({
url: 'insert_value.php',
data: jsonString,
contentType: 'application/json; charset=utf-8',
type: 'POST',
}).done(function(resp) {
$('#result').html(resp)
});
</script>
&#13;
这里它没有在控制台上显示控件的值,也给出了一些详细信息,如[Violation]添加非被动事件监听器到滚动阻塞的鼠标轮&#39;事件。考虑将事件处理程序标记为“被动&#39;使页面更具响应性。所以我现在应该做什么
答案 0 :(得分:0)
<script>
function myFunction() {
var query = '?';
var str = $("form").serialize();
$("#results").text(query += str);
var x = $("#results").text();
return x;
}
$( "input[type='sel'], input[type='text']").on( "click", myFunction);
$( "select" ).on( "change", myFunction);
//window.alert(myFunction());
//query += '&' + value + '=' + value +'.value';
var jsonString = JSON.stringify(myFunction());
console.log(jsonString);
$.ajax({
url: 'insert_value.php',
data: jsonString,
contentType: 'application/json; charset=utf-8',
type: 'POST',
}).done(function(resp) {
$('#result').html(resp)
console.log('console', resp);
});
</script>
&#13;
答案 1 :(得分:0)
答案 2 :(得分:0)
function myFunction() {
var query = '?';
var str = $("form").serialize();
$("#results").text(query += str);
var x = $("#results").text();
return x;
}
$( "input[type='sel'], input[type='text']").on( "click", myFunction);
$( "select" ).on( "change", myFunction);
//window.alert(myFunction());
//query += '&' + value + '=' + value +'.value';
var jsonString = JSON.stringify(myFunction());
console.log(jsonString);
$.ajax({
url: 'insert_value.php',
data: jsonString,
contentType: 'application/json; charset=utf-8',
type: 'POST',
}).done(function(resp) {
console.log(resp);
$('#result').html(resp)
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="result"></div>
&#13;
这是简单的代码段。这将显示控制台中ajax响应的输出以及屏幕上的显示(带有id结果的div)。希望这会对你有帮助..
问候!