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

  • Home
  • SEARCH
  • 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 483785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:13:58+00:00 2026-05-13T01:13:58+00:00

I have a bookmarklet that when clicked opens up a div popup on their

  • 0

I have a bookmarklet that when clicked opens up a div popup on their current page(e.g. http://www.cnn.com). This div has a button that that when clicked makes a jQuery.get request to my application domain. This is all working fine, but I am getting an error on the response. This is the function that makes the request

function postWishXML(){

  jQuery(".ServerResponse").ajaxError(function(event, XMLHttpRequest, ajaxOptions){
    //entering here
  });

  var Wish = wishObject();

  if(Wish == false)
  {
    jQuery('.ServerResponse').html('Please enter a gift title');
    jQuery('.GiftText').val('');
  }else
  {
    jQuery('.ServerResponse').html('');
    var WishXML = createXMLTags(Wish);

    jQuery.get(Root+'/apps/shop/toolbar/WishlistPopup.ashx',
       {'sap':Cookie,'wish':WishXML},
        Response,
       'text'
     );
  }

}

this is the server code

 public void ProcessRequest (HttpContext context) {


    if (SecurityContext.IsAuthenticated || SecurityContext.IsSemiAuthenticated)
    {

        if (!string.IsNullOrEmpty(context.Request["wish"]))
        {
            string res = "Your wish has been added";
            context.Response.ContentType = "text/plain";
            context.Response.Write(res);
            context.Response.End();

        }
    }

Is my problem something to do with cross domain scripting or syntax?

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-05-13T01:13:59+00:00Added an answer on May 13, 2026 at 1:13 am

    I think you’re right. It looks like you’re hitting on a cross-site scripting limitation.

    Remember, you’re inserting your javascript code into the target website’s code. Therefore, it’s just like the code is running from their page. In other words, you’re attempting to make an AJAX request from within the page (e.g., http://www.cnn.com) and retrieve data from your site (another domain).

    One solution I found in an article here. This is the gist:

    function loadScript(scriptURL) {
     var scriptElem = document.createElement('SCRIPT');
     scriptElem.setAttribute('language', 'JavaScript');
     scriptElem.setAttribute('src', scriptURL);
     document.body.appendChild(scriptElem);
    }
    
    loadScript(Root + '/apps/shop/toolbar/WishlistPopup.ashx');
    

    Make your server script return javascript that will be eval’ed.

    A second, probably more preferred option is to use JSONP. Essentially, your server will respond with JSON data wrapped in a named function. You tell the jQuery.ajax request you expect a jsonp response and what the name of the returned function will be. This is pretty much doing the above, but with a little more safety and syntactic sugar wrapped around it.

    This would be the PHP version, but it should get the point across. Assume all the data you need is in $data and keep in mind that you could put anonymous functions in the JSON structure to be eval’ed in success handler.

    $json = json_encode($data);
    echo $_GET['jsonp_callback'] . '(' . $json . ');';
    

    The javascript:

    $.ajax({
      dataType: 'jsonp',
      jsonp: 'jsonp_callback',
      url: Root + '/apps/shop/toolbar/WishlistPopup.ashx',
      success: Response,
    });
    

    To give proper credit, I stole and modified this JSONP example from Andrew Moore’s answer for this question

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

Sidebar

Ask A Question

Stats

  • Questions 257k
  • Answers 257k
  • 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 might want to verify the result of your server.mappath… May 13, 2026 at 10:46 am
  • Editorial Team
    Editorial Team added an answer The code might be alright, when i run it on… May 13, 2026 at 10:46 am
  • Editorial Team
    Editorial Team added an answer <% form_tag({}, :method => :get, :name => "whatever") do %> May 13, 2026 at 10:46 am

Related Questions

I have a Javascript bookmarklet that, when clicked on, redirects the user to a
I have a pretty typical bookmarklet code that's working perfectly for me in all
I have written a Firefox extension that catches when a particular URL is entered
I'm working on a bookmarklet that gives the full path to an image when

Trending Tags

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

Top Members

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.