我已经更新了ajax,但仍然没有传递任何东西,我变得疯狂,请有人帮助我。它必须工作:(
function ajaxFunction(gotid){
alert (gotid)
$.ajax({
type: "POST",
url: "profile/php/getorder.php",
data: {
dataString: gotid
},
success: function(msg){
alert( "Data Saved: " + msg );
}
});
}
和PHP
<?php
$ordid = $_POST["dataString"];
$ordid = mysql_real_escape_string($ordid);
echo $ordid;
?>
为什么看不到警报(“Data Saved:”+ msg); ?帮助:(
答案 0 :(得分:0)
如果您在页面中使用jquery(如问题标签中所述),您最好使用它!无需使用XMLHttpRequest。看看这个jquery片段和jquery文档 http://api.jquery.com/jQuery.ajax/
$.ajax({
url: '/path/to/file',
type: 'default GET (Other values: POST)',
dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
data: {param1: 'value1'},
})
.done(function() {
console.log("success");
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});