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 1015753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:26:53+00:00 2026-05-16T10:26:53+00:00

I am looking to create a variable that is a template for repatative elements

  • 0

I am looking to create a variable that is a template for repatative elements of my site. I however am only using it infrequently so I do not wish to use a javascript templating engine or library.

I am using jquery… if that effects anyones approach.

This is one of my templates.

$html_template = json_encode("
var html = '<a href=\"javascript:ajax(\'#content\',\'{$conf['dir']['web_url']}profile.php?user_id='+data.id+'\');\">
<div id=\"'+data.id+'\" class=\"fb_user\">
    <img alt=\"'+data.name+'\" height=\"50\" width=\"50\" />
    <p>
        '+data.first_name+'
        <br/>
        '+data.last_name+'
    </p>
</div>';");

I have gotten so lost in escaping I can’t work out where I have gone wrong. The plan is to use eval within the templating function to replace the variables.

Hope someone can 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-16T10:26:53+00:00Added an answer on May 16, 2026 at 10:26 am
    1. Use an editor with good highlighting and you will see where to escape.
    2. The apostrophes (‘) that are inside the javascript code shouldn’t be escaped, use double backslash (\) instead, so the javascript will see a single backslash and therefore will escape the apostrophe.
    3. In the anchor don’t use javascript code as href, use “#” for link and add onClick=”…”.
    4. I don’t think “ajax” is a jQuery function, perhaps you meant “$.ajax”, but it has different parameters, may be you should read its manual.
    5. Try to implement it in pure html and js before writing it in php and you’ll know where to escape (after it works in first place).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Until now, I have not create any massive applications using ASP.Net. However, I am
I'm looking to create a jQuery script that will replace an html variable if
I looking to create a custom calender with Zend Framework, I am hoping that
Im looking to create a control that would look like comic baloon. In WPF
I'm looking to create a portfolio using a Wordpress blog. On the summary page
I am looking to create a reg ex in JS that obtains 2 values
I'm looking to create a read-only table, and MYSQL permissions, I think, are the
I am looking to create something that resembles a table in Tkinter but it
I'm looking to create a windows program that doesn't require any environmental dependencies (like
Is it possible to create a django template that can be used (nested) inside

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.