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

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You are removing the control that has the focus. It… May 16, 2026 at 3:58 pm
  • Editorial Team
    Editorial Team added an answer I think this may make it compile: def getHandler[H <:… May 16, 2026 at 3:58 pm
  • Editorial Team
    Editorial Team added an answer Use: SELECT t.job, SUM(CASE WHEN t.transaction_type = 'TransType1' THEN t.amount… May 16, 2026 at 3:58 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

In PHP one can create a reference variable, so that two named variables can
I'm looking to create a solution for a asp.net mvc app that displays unstructured
I am looking to create a function that could create a fade-in/fade-out function on
My goal here is to create a very simple template language. At the moment,
I am looking for a way to create dynamic preferences where I don't need
I'm looking to create a histogram in SQL (which in itself isn't too tricky),
I have a MySQL table and I am looking to create a stats page
I'm trying to create an inventory list (tab-delimited text, for the output) from XML
I have code that I expect to return the element name, but nothing is
Greetings, I'm looking for a method to do in-line result (output) document selecting in

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.