Php 如何将ajax post响应保存到数据库中?
我的密码在这里Php 如何将ajax post响应保存到数据库中?,php,jquery,mysql,ajax,Php,Jquery,Mysql,Ajax,我的密码在这里 <script type="text/javascript"> function test(){ alert('return sent'); $.ajax({ type: "POST", url: "http://remotewebsite.com/process.php", data: somedata; dataType:'tex
<script type="text/javascript">
function test(){
alert('return sent');
$.ajax({
type: "POST",
url: "http://remotewebsite.com/process.php",
data: somedata;
dataType:'text'; //or HTML, JSON, etc.
success: function(response){
alert(response);
//echo what the server sent back...
}
});
}
</script>
功能测试(){
警报(“已发送返回”);
$.ajax({
类型:“POST”,
url:“http://remotewebsite.com/process.php",
资料:部分资料;
数据类型:'text';//或HTML、JSON等。
成功:功能(响应){
警报(响应);
//回显服务器返回的内容。。。
}
});
}
但如何将来自远程网站的响应保存到我的数据库中呢?
如何发送多个输入
$.ajax({
type: "POST",
url: "http://remotewebsite.com/process.php",
data: somedata;
dataType: 'text'; //or HTML, JSON, etc.
success: function(response) {
alert(response);
$.ajax({
type: "POST",
url: "youphppagewhereyoudothesavingindatabase",
data: response;
dataType: 'text'; //or HTML, JSON, etc.
success: function(data) {
console.log(data);
alert("Saved in database")
}
});
}
});
有这样的功能当您第一次成功时,您可以调用另一个ajax请求。在第二个ajax中,保存数据,然后返回成功警报。我不确定这是否会很慢,只是我的想法,我不需要速度,但我如何才能完成第二个请求?创建另一个ajax,就像您拥有的一样,并使用
响应作为数据使用post方法并将其保存到数据库。您可以使用类似于$的内容http://remotewebsite.com/process.php",数据:somedata;数据类型:'text';//或HTML、JSON等。成功:函数(响应){alert(响应);$.ajax({type:'POST',url:'youphppagewhereyoudothesavinginadabase',数据:响应;数据类型:'text';//或HTML、JSON等。成功:函数(响应){console.log(response);alert(“保存在数据库中”)}}}}};
感谢您的帮助,您可以将其作为答案发布,以便我可以将其标记为正确答案吗?:)