Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6751891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:58:52+00:00 2026-05-26T12:58:52+00:00

Hmm… i’m trying to use a php variable in jquery, in my edit.php :

  • 0

Hmm… i’m trying to use a php variable in jquery, in my edit.php : i’d like to use jquery to show the php variable, using the “rel” attribute, but it gives me the “name” of the variable, not its content.

i’m using php to retrieve the text from the xml file : (edit : one click on submit does not update the text, but 2 clicks do)

/* READ */
$dom = new DomDocument();
$dom->load('edition.xml');

$_home = $dom->getElementsByTagName('home')->item(0);
$home = $_home->firstChild->nodeValue;

$_rhizo = $dom->getElementsByTagName('rhizo')->item(0);
$rhizo = $_rhizo->firstChild->nodeValue;

$_disco = $dom->getElementsByTagName('disco')->item(0);
$disco = $_disco->firstChild->nodeValue;

/* array */
$rels = array('home' => $home,
'rhizo' =>$rhizo,
'disco' =>$disco);

echo '<script>var rels = ' . json_encode($rels) . '</script>';


/* WRITE */
if ( isset($_POST['cache']) ){

    if ( isset($_POST['home']) ){
     $home = stripslashes($_POST['home']);
     $_home->firstChild->nodeValue = $home;
    }

    if ( isset($_POST['rhizo']) ){
     $rhizo = stripslashes($_POST['rhizo']);
     $_rhizo->firstChild->nodeValue = $rhizo;
    }

    if ( isset($_POST['disco']) ){
     $disco = stripslashes($_POST['disco']);
     $_disco->firstChild->nodeValue = $disco;
    }

    $dom->save('edition.xml');

}
?>

(the text is simply shown in a textarea, where i just put the php variable)
then i use jquery to show the content from the php variable : (edit with the array object : )

$('#left a').bind('click', function(){

    var text_from_link = $(this).text();

    var rel = $(this).attr('rel');
    $('#textarea1').attr('name', rel);

    $('#textarea1').text(rels[''+rel+'']);//output is "$home" for example, which will retrieve the "home" part from the xml

    return false;
})

And this works if i double click on submit, if i just click once, the text is not updated… i’m a bit confused with that

Thanks for your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:58:52+00:00Added an answer on May 26, 2026 at 12:58 pm

    You need to do an ajax call to do that.

    Or you can write a javascript object in your HTML:

    $rels = array('rel23' => 'Hello world');
    echo '<script>var rels = ' . json_encode($rels) . '</script>';
    

    Then access them with javascript:

    alert(rels.rel23);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT 1 Hmm, I accept the answers that tar respects an empty file... but
Hmm, sounds easy enough but after looking at the ones that come with StringTemplate,
[EDIT] Hmm. Perhaps this question should be titled what is the default user-input dialog
I'd like to format a duration in seconds using a pattern like H:MM:SS. The
Hmm. Instead of defanging input or using some kind of regex to remove tags,
I already asked here with no luck, but feel free to read it: http://groups.google.com/group/jquery-en/browse_thread/thread/fdf7a584b30d4bb9
Hmm... Title is a bit of a mouthful, but I'm really not sure which
Hmm I can't really indentify any insecurities but was wondering whether you can, if
Hmm this is strange. It works in IE but not FF. Please take a
I am using a plugin named : jkey . Now i want to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.