当前位置:Gxlcms > PHP教程 > js如何取得ueditor里的值啊

js如何取得ueditor里的值啊

时间:2021-07-01 10:21:17 帮助过:25人阅读

我现在想用ajax的$post给服务器端传值,如何获取ueditor里的值呢,我的页面加载代码如下:


页面能显示出来ueditor。
我现在用jq呀js通过id“blog_content”取到的值alert出来全是空,取不到这个值,我如何$post这个值啊。。。。请高手解答


回复讨论(解决方案)

1. editor.getContent() 直接用 ueditor对象方法
2.$('#blog_content').val() ,你确定值在blog_content里

我查了editor的API,我看着有editor.getContent() 这个方法,我也用了,也是空。我不确定值是不是在blog_content里,用$('#blog_content').val();的值也是空。。。

我查了editor的API,我看着有editor.getContent() 这个方法,我也用了,也是空。我不确定值是不是在blog_content里,用$('#blog_content').val();的值也是空。。。


那应该是你搞错对象,找错
UE.getEditor('editor').getContent() 用这看看

之前刚做过。。。。直接$('#blog_content').val() 就ok了 没那么复杂。。。

之前刚做过。。。。直接$('#blog_content').val() 就ok了 没那么复杂。。。


那我取出来的值为啥是空呢


我搞错了。。。这个很久前弄过次。。。我改用别的了 说真还得去看下文档

引用 2 楼 blackartrock 的回复:我查了editor的API,我看着有editor.getContent() 这个方法,我也用了,也是空。我不确定值是不是在blog_content里,用$('#blog_content').val();的值也是空。。。
那应该是你搞错对象,找错
UE.getEditor('editor').getContent() 用这……


这个方法好用,能取到值了,谢谢。
不过ajax的post提交为啥跳转了,还在地址栏转值呢?
http://blog.local/index.php/admin/blog_c/insertBlog?blog_title=&select_category=%E8%AF%B7%E9%80%89%E6%8B%A9%E6%97%A5%E5%BF%97%E5%88%86%E7%B1%BB&blog_content=%3Cp%3Eaa%3Cbr+%2F%3E%3C%2Fp%3E

看看你的 .post 怎么写的。。。估计是写错了

你用的是什么ajax包
比如 jquery包的,
$.post(url,{blog_content:....,select_category:...},function(){
alert('完成')
})

url = "http://blog.local/index.php/admin/blog_c/insertBlog"
.post(url,{blog_title:UE.getEditor('editor').getContent()},function(d){});

OK?

看看你的 .post 怎么写的。。。估计是写错了



$.post("",
{blog_title:blog_title,blog_category:blog_category,blog_content:blog_content},
function(data){
$(".category_list").html(data);
});
提交的一顺点我看间firebug里有提交请求,但是,是红色的,跳转后就看不见了

你先直接 alert 要提交各项的 值 是不是你要的。。。虽然笨点,,但一看就晓得哪里错了

你先直接 alert 要提交各项的 值 是不是你要的。。。虽然笨点,,但一看就晓得哪里错了


alert出来的值没问题,我每一项都显示了,都是我想要的值,但是php接收不到post

$_POST['blog_content'],输出这个,说是变量blog_content未定义。我想应该是post提交没成功,因为我看到firebug里有红色。。。。


有红色,但是马上就跳转到下个页面了,所以没法点开看

我也不晓得问题在哪里。。。。但按自己的情况来说
我就先看 firebug 提交到的 地址有没有错 。。。还有到底有底提交到没。。。
之前弄其他编译器的时候 也出现过同样的问题的。。。。
最后就是查看前后代码 哪里写错了 才解决的。。

用 google chrome 试试

你用的是什么ajax包
比如 jquery包的,
$.post(url,{blog_content:....,select_category:...},function(){
alert('完成')
})


我用的就是jquery包啊,发代码了,帮我看下问题出在哪儿了

你把前后的也发下 。。。包括blog_title,blog_category:blog_category,blog_content:blog_content
赋值那里。。。我现在比较蛋疼。。。研究研究

用 google chrome 试试


刚下了个chrome,看下图,怎么变Get了。。。。。。

这个问题我找着原因了,是我的写法有问题,我在button里写了个onclick事件,然后调研了一个方法,但是,我想,$.post只能运行在$(function(){});里吧,我重写了一下,给button加了个class,去掉了onclick,然后用jq写了个click,就好用了,感谢各位的帮忙,结贴了。


引用 2 楼 blackartrock 的回复:我查了editor的API,我看着有editor.getContent() 这个方法,我也用了,也是空。我不确定值是不是在blog_content里,用$('#blog_content').val();的值也是空。。。
那应该是你搞错对象,找错
UE.getEditor('editor').getContent() 用这……


这个方法好用,能取到值了,谢谢。
不过ajax的post提交为啥跳转了,还在地址栏转值呢?
http://blog.local/index.php/admin/blog_c/insertBlog?blog_title=&select_category=%E8%AF%B7%E9%80%89%E6%8B%A9%E6%97%A5%E5%BF%97%E5%88%86%E7%B1%BB&blog_content=%3Cp%3Eaa%3Cbr+%2F%3E%3C%2Fp%3E




UE.getEditor('editor').getContent() 这句话是写在 js 里面吗? 我写这个怎么也包空呢?求大虾指教.

var conte = UE.getEditor('editor').getContent();
alert(conte);
我在js里写的取不到啊..

问题是对 的处理,如果ajax提交的内容中含有 ,$_POST("name")获取到得是 前面的值

人气教程排行