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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:21:23+00:00 2026-06-01T03:21:23+00:00

I am writing a web page widget for my company. This widget must inject

  • 0

I am writing a web page widget for my company. This widget must inject an HTML snippet from any domain (our website, possibly a customer CNAME) into the customer’s website, which may be on any domain (Tumblr, blogspot, mydomain.com, etc.)

JQuery.load() would do exactly what I’d like it to do, except I don’t think it will work with JSONP.

At this point I’ve chosen on the client-side to use a standard JQuery.ajax() GET call using JSONP that calls to the server. The server returns an object with a single attribute (the html to inject), which is kind of working except for the fact that I’m still working on making it not choke on the HTML payload. Seems if I escape the HTML, it passes through like a charm, but I’m looking for a better way…

FWIW, I am running RoR on the server-side. Any ideas on best practices to get this to work?

This is the code I’m using on the client:

$.ajax({
dataType: 'jsonp',
url: "http://test.host:3000/widgets/widget_1?username=foo",
crossDomain: true,
success: function(data) { $("#my-div").html.(data.foo) }
});

And what I’m returning from the server:

JQueryCallback({"foo": "<div>bar</div>"})

And the error I get in the Firebug console:

unterminated string literal (pointing to the beginning of the open tag in the div)

I think its choking on the , but I’m not sure how to get around this, or if this is the best way to go about it.

Thanks!

  • 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-06-01T03:21:25+00:00Added an answer on June 1, 2026 at 3:21 am

    thanks for the help. the main issues I was having was:

    1. extra dot after the html() method and
    2. I wasn’t properly escaping
      the JSON.

    I am using to_json now to better encode the html going out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A friend of mine is programming a web page. Instead of writing any HTML
I'm writing a widget that pulls data from a web page every 5 minutes,
Writing a small HTML web page with some very simple Javascript in it, I
I am writing a web page that selects certain fields from a database that
I'm writing a Bash script to download image files from Snapito 's web page
I'm writing a website that allows people to asses a web page's readability (Flesch-Kincaid
I'm writing a lisp program to fetch a web page of a Chinese website,
I'm writing a web page that has a from field that allows a user
I am writing a web page that uses some php files. The php isn't
When writing a query for paging on a web page what is the least

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.