当我从同一页面上的表单输入发布一个数字时,我试图让JustGage刷新而不重新加载整个页面。
$(document).ready(function(){
//JSON REQUEST
$.getJSON("test_server.php",function(result){
var g = new JustGage({
id: "gauge",
value: result.total,
min: 0,
max: 100,
title: "Data from Form"
});
});
//Post Form
$("#submitButtonId").on("click",function(e){
e.preventDefault();
var formdata = $(this.form).serialize();
$.post('test_server.php', formdata, function(data){
//Reset Form
$('#myform')[0].reset();
});
return false;
});
});
</script>
jQuery的:
<?php
$total= mysqli_real_escape_string($db_conx,$_POST['total']);
$my_data=array(total=>"$total");
// sending output
header('Content-Type: text/json');
echo json_encode($my_data,true);
?>
test_server.php:
let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("someViewController") as! ViewB
/* Here you have the reference to the view, so you can set the parameters*/
vc.parameterInViewB = banana
/* At this point you can present the view to the user.*/
self.presentViewController(vc, animated: true, completion: nil)