这里的Everthing工作正常,只是在保存的文件中它没有给我整个字符串。 只有一个ID(页面上有多个)。 p>
不确定如何获取$ .ajax() p> 中的“所有ID和内容”
我做错了什么? p>
有这个jquery: p>
$('a#exportPage')。 on('click',function(){
var contentMap = {};
$('[id ^ =“appendHeading”]')。each(function(){
contentMap [this.id] = $( 这个).text();
});
for(contentMap中的id)
$(“#PrintIds”)。append(“ObjectID:”+ id +“Content:”+ contentMap [id]); \ n
$ .ajax({
url:“post.php”,
type:“post”,
data:{
objectID:id,
content:contentMap [id]
},\ n success:function(){
alert(“success”);
},
error:function(){
alert(“failure”);
}
});
});
code> pre>
这个PHP: p>
<?php
if($ _POST ['objectID'] | | $ _POST ['content']){
$ myFile =“test.css”;
$ stringData = $ _POST ['objectID'] || $ _POST ['content'];
file_put_contents($ myFile,$ stringData);
}
?>
code> pre>
div>