对不起,我删除了我的旧答案,看起来你在某个地方有语法错误(我找不到)
这就是我应该做的,我没有编程太多,但我认为这是一种可以做的方式。
请问我是否有什么可以帮忙的
<form id="idForm">
<div>
<label>Your name:</label>
<input type="text" id="customerName" />
</div>
<div>
<label>Your email address:</label>
<input type="text" id="customerEmail" />
</div>
<div>
<label>Details about your enquiry:</label>
<textarea id="customerRequest" cols="45" rows="4"></textarea>
</div>
<input type="hidden" id="propertyid" value="@rPropertyId">
<button id="submitButtonId" type="submit" class="btn btn-default" value="Submit">Submit</button>
</form>
<script>
$(document).ready(function () {
$('#idForm').submit(function (){ // If the form was submitted
var customerName = $('#customerName').val(), // All the values from the fields...
customerEmail = $('#customerEmail').val(), //
customerRequest = $('#customerRequest').val(), //
propertyid = $('#propertyid').val(); //
$.post("PATH/FILENAME.php", // The php-file to process the data
{
// In the php-file, use $_POST['customerName']; --> etc
customerName : customerName, // all the values + their names
customerEmail : customerEmail,
customerRequest : customerRequest,
propertyid : propertyid
},
function(data){ // What to do with the data when finished.
alert(data); // Data is the same as whats beeing echo'ed in the php-script
});
});
});
</script>