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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:12:37+00:00 2026-05-16T03:12:37+00:00

Here is my problem: I’m developing a system that can be polled to retrieve

  • 0

Here is my problem: I’m developing a system that can be polled to retrieve dynamic data. It’s in Grails, and when I do a request on a certain controller action, say “http://localhost:8080/foo/bar“, a JSON list is returned containing the latest data.

For added security and functionality, I protected my page using Spring Security (Grails Acegi plugin), with Basic Authentication enabled. When you log in, the system automatically loads information regarding your user profile, and that changes the data that is returned. So, authentication is mandatory.

This works: I can poll my action from any browser, and the data will be returned. I have a JavaScript script in my Grails application that calls this URL.

The problem is that I would like to externalize my JavaScript script to distribute it to customers, so they can build their own HTML file, plug in my JavaScript file, and be able to access my data (kind of like an API) using AJAX. Like so:

$.ajax(url: urlWithParams, 
       method: 'GET', 
       beforeLoad: function(xhr) { 
           xhr.setRequestHeader('Authorization', authString);
       },
       success: myFunction
});

However, it doesn’t work. First of all, I know cross-domain GET requests are tricky. But in my case, I use Basic Authentication, which is trickier, because I need to put the credentials into the XmlHttpRequest directly, and that produces preflighted requests in Firefox (replacing GET by OPTIONS), and my Grails application doesn’t deal with it.

My problem is very specific. I use Basic Authentication to prevent malicious access, however I can’t access my application using proper credentials because of some cross-domain restrictions!

What should I do! I tried with an IFrame, but I can’t get the page content (I get an “Access Denied” error – yet again cross-domain restrictions).

Also, jQuery username and password fields in the ajax() function don’t work.

Could I do a simple AJAX GET request on an unprotected page, sending credentials as parameters, and then the page would redirect to the protected page using the credentials? The browser wouldn’t mangle the request, but can I do a redirect with Basic Authentication credentials?

I have a feeling that it won’t work (something to do with the redirect, which generates a new request, etc…). Am I right, or should it work?

Could JSONP solve this problem? I don’t know how to integrate Basic Authentication using JSONP, however…

Thank you very much!

  • 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-16T03:12:37+00:00Added an answer on May 16, 2026 at 3:12 am

    I solved my question using JSONP. I modified my application so as not require basic authentification for the AJAX call. The $.getJSON() method from jQuery did the trick.

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

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 499k
  • 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 This sounds very strange. Can you double check your database… May 16, 2026 at 12:43 pm
  • Editorial Team
    Editorial Team added an answer You need to prevent the default action of the link… May 16, 2026 at 12:43 pm
  • Editorial Team
    Editorial Team added an answer This JQuery plugin might be interesting for you: http://www.ajaxupdates.com/an-iphone-scrolling-plugin-for-jquery/ May 16, 2026 at 12:43 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

Here the problem. I have my site hosted on a shared hosting for asp.net
Got an annoying problem here. I've got an NHibernate/Forms application I'm working through SVN.
I have an interesting problem here... <cfloop from=1 to=#form.countField# index=i> <cfif isdefined('form[semester#i#]')> <cfquery name
i'm having a small problem here. I'm using a simple rule to redirect all
I'm having a little bit of a problem here, whenever I use an action
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I've got some problem with my function and don't know how to solve this
What is the efficient way of blocking on the socket for data after opening
I have added some backgrounds on stage and then on top of that adding
Ok, I hope I've got everything listed up nicely before posting this question because

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.