在刷新/事件时修改页面请求


Modify a page request on refresh/event

我正在编写一个博客编辑器,当POST请求到达页面时加载,例如blog_editor.php。post request数据看起来像blog_title="This is blog title"

现在,blog_editor.php从post请求中读取博客标题,如果存在,则从数据库中读取blog_id,并且内容已准备好编辑,否则将创建一个新的数据库条目。

现在我已经给出了一个内联编辑blog_title的选项,应该使用ajax保存。

My problem here is, the page is looking for a unique blog_title. If user modifies the blog title inline and then does a page refresh, it creates a new blog with old blog_title as POST request still contains old title.

我能以某种方式修改这个帖子数据吗?

如果您打算在ajax上更新博客标题,则不应该使用与POST请求相同的功能。

在ajax示例中,您需要blog_id,因为意图是更新用户修改的博客。

根据你当前的功能,每当用户编辑标题,应该考虑作为新标题,你得到基于标题的blog_id。

解决方案:在情况下,你没有blog_id在第一时刻,把你的原始标题在一些隐藏的字段或分配给一些javascript变量在页面加载和发送原始和用户修改的标题在Ajax请求和获得基于原始标题的blog_id和描述,并允许与新标题编辑。