这是我的AJAX请求的一部分.它工作正常 - 发送code到index.php
但是当我想(div id="editor")从响应中得到一些内容时,我只得到类似的东西[object Object]
$.ajax({
url: 'index.php',
type: 'GET',
data: {
content: code
},
success: function(data){
alert($('#editor'));
}
Run Code Online (Sandbox Code Playgroud)
当我将功能更改为:
success: function(data){
alert(data);
}
Run Code Online (Sandbox Code Playgroud)
我正在获取整个页面源代码
您需要更改jQuery搜索的范围.(这是jQuery选择器的第二个参数,默认情况下是'document').
alert($('#editor',data));Run Code Online (Sandbox Code Playgroud)
此外,您当前正在获取[对象对象],因为警报无法在没有任何帮助的情况下将对象拆分为sting.尝试console.log($('#editor',data))或alert($('#editor',data).html())
| 归档时间: |
|
| 查看次数: |
1748 次 |
| 最近记录: |