当我点击按钮时,动画会运行但跳过ajax。这只是智能手机屏幕上的一个问题,而不是我的电脑上的问题。
Jquery的:
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('#thisid').hide();
$("#button-create").on('touchstart',(function(event) {
var name = $("#create").val();
var name2 = $("#create2").val();
$("#stage").load('result.php', {name:name, name2:name2} );
});
});
</script>
按钮:
<button id="button-create" class="btn1">Create</button>
HTML
<div class="col-xs-12 col-lg-6 col" style="text-align:center;">
</div>
<div class="col-xs-12 col-lg-6 col" style="margin-top:20px;text- align:center;">
<input type="input" style="height:24px; margin-right:15px;" id="create" value="Heading">
<button id="button-create" class="btn1">Create</button>
</div>
</div>
</div>
<input type="input" style="float:right; display:none;" id="create2" value="<?php echo $_GET['user']?>">
<div id="stage">
</div>
<input type="input" id="headv" size="40" style="display:none;">
<div id="stage100">
</div>
Result.php
<?php
if( $_REQUEST["name"] )
{
$name = $_REQUEST['name'];
$name1_preg = preg_replace('/\s+/', '-', $name);
$name2 = $_RsEQUEST['name2'];
$content = 'Click to edit me, press the save button to save';
session_start();
try {
$pdo = new PDO('mysql:host=localhost;dbname=cms', 'root', 'root');
} catch (PDOException $e) {
}
$query123 = $pdo->
prepare("INSERT INTO post (head, user, content) VALUES (?, ?, ?)");
$query123->
bindValue(1, $name1_preg);
$query123->
bindValue(2, $name2);
$query123->
bindValue(3, $content);
$query123->
execute();
}
?>