正在更新< div>带有前一页中值的文本 [英] Updating <div> text with value from the previous page

查看:99
本文介绍了正在更新< div>带有前一页中值的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用下面的代码点击修改按钮后,我将用户从另一个页面重定向。

  $('#editListButton')。click(function(){
window.location.href =http ://localhost/yyy.php; //重定向

//需要做的更改
$('#defaultText')。remove();
$ ('#orderList')。append('< p'+'message'+'< / p>');
});

页面重定向到预定义的链接,之后我需要更新html < div> 标签和文字。但是来自其他页面的代码却什么都不做。如何更改div标签中的文本?

解决方案

有很多方法可以将信息从一个页面传递到另一个页面。为了给出这个概念的一个概念,有些与发布的问题有关,这里是一个:



页面A:

< pre $ $('#editListButton')。click(function(){
window.location.href =http://localhost/yyy.php?action = remove& value =+
encodeURIComponent('ashdahjsgfgasfas');
});

页面B:

  var action = /(?:\?|&)action=([^&$]+)/.exec(location.search)
if('remove'== = action [1]){
var value = /(?:\?|&)value=([^&$]+)/.exec(location.search)
$( '#defaultText')除去();
$('#orderList')。append('< p> + value [1] +'< / p>');
}


I'm redirecting the user from another page when they click the "Edit" button using the code below.

$('#editListButton').click(function(){ 
    window.location.href = "http://localhost/yyy.php";  //redirect

   // Changes that need to be made
   $('#defaultText').remove();
   $('#orderList').append('<p' + 'message'  + '</p>');
}); 

The page redirects to the predefined link, after which I need update a html <div> tag with text. But the code coming from the other page does nothing. How can change the text in the div tag?

解决方案

There are many ways to pass information from one page to another. To give an idea of the concept, somewhat in relation to the question posted, here's one:

Page A:

$('#editListButton').click(function(){ 
  window.location.href = "http://localhost/yyy.php?action=remove&value=" + 
    encodeURIComponent('ashdahjsgfgasfas');    
});

Page B:

var action = /(?:\?|&)action=([^&$]+)/.exec(location.search)
if ( 'remove' === action[1] ) {
    var value = /(?:\?|&)value=([^&$]+)/.exec(location.search)
    $('#defaultText').remove();
    $('#orderList').append('<p>' + value[1]  + '</p>');
}

这篇关于正在更新&lt; div&gt;带有前一页中值的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆