所以我的js:
$('#introorderbtn').click(function () {
var display = document.getElementById("display").value;
var skype = document.getElementById("skype").value;
var music = document.getElementById("music").value;
var ideas = document.getElementById("ideas").value;
$.post('php/intro.php',{id:ID,gname:gname,name:Name,email:email,display:display,skype:skype,music:music,ideas:ideas}, function(data) {
});
jQuery.ajax({
url: 'php/file.php',
type: 'post',
data: {id:ID,gname:gname,name:Name,email:email,display:display,skype:skype,music:music,ideas:ideas},
success: function(data){
$('#results').html(data);
$('#display').val = "";
$('#skype').val = "";
$('#music').val = "";
$('#ideas').val = "";
}
});
});
我的HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div style="display = none" id="gal">
<h1>Order a free Introduction</h1>
<p>This is a 2D Intro: about 7 sec. long and choisable with an alpha-transition (so called "Opener").<br>They are in 1920x1080px and 60fps of course!<br> Most clients picked this product, do it like them!<br> When you are not sure about my art, take a look into the Gallery.</p>
<form>
<h1>Gimme some Data:</h1>
<input id="display" type="text" placeholder="Name Displayed in the Intro">
<input id="skype" type="text" placeholder="Your Skype ID">
<input id="music" type="url" placeholder="Music (No Dubstep Trap stuff pls)">
<textarea id="ideas" placeholder="Your Ideas: "></textarea>
<input type="submit" id="introorderbtn">
</form>
<div id="results"></div>
这是我的php
<?php
$id = $_POST['id'];
$gname = $_POST['gname'];
$name = $_POST['name'];
$email = $_POST['email'];
$display = $_POST['display'];
$skype = $_POST['skype'];
$music = $_POST['music'];
$ideas = $_POST['ideas'];
echo("Test");
---msql connection that works 100%---
?>
php单独使用没有问题,但是当我尝试发布表单中的数据以及其他脚本中的更多字符串时,它并没有。 成功功能正在运行,但它没有显示结果。
答案 0 :(得分:0)
我看到的第一个问题是
dataType: JSON,
应该是
dataType: 'JSON',
或者只是将其关闭,因为jQuery应该能够自动解决它。
另外,我认为您需要更改
$('#results').html(data);
为:
$('#results').html(JSON.stringify(data));
或至少不是对象的东西。
当然,假设data
实际上以json
的形式返回,正如您所指出的那样。