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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:27:44+00:00 2026-06-18T22:27:44+00:00

I am trying to make a request across domains like that: var script=document.createElement(‘script’); script.setAttribute(‘src’,http://www.example.com/wordpress/register/?callback=callbackF&ver=2.5&url=+encodeURIComponent(window.location.href));

  • 0

I am trying to make a request across domains like that:

    var script=document.createElement('script');
    script.setAttribute('src',"http://www.example.com/wordpress/register/?callback=callbackF&ver=2.5&url="+encodeURIComponent(window.location.href));
    script.setAttribute("type", "text/javascript");
    script.setAttribute("id", "spark_grazit_script");
    document.getElementById("spark_static_widget").parentNode.appendChild(script);

As the script will be created, it will be appended to the div that i have and there will be a request. At the end of the request:

   function callbackF(data){
            console.log('Response has finished'+data);
        }

That function should be triggered at the end of the request. All I want is to get the callback function called.

I dont get a cross domain error. But I get this error:

Uncaught SyntaxError: Unexpected token : 

Is there a way to achieve what I want without resorting to html5 or jsonp. Can I somehow still get a response with ajax?

UPDATE:
The response is a simple json object

This is the response:

{ "userid":"24645", "token":"40A164ECA4DE4A4F", "script":"<script type='text/javascript'>var dbnwid=16211; var dbnpid=23113; var dbnwebid=19459; var dbnlayout=21; var dbncolor='#000000'; var dbntitlefontsize='14'; var dbnbgcolortype=1; var dbnheader='You might enjoy reading:'; var dbnremindercolor=2; var dbn_protocol = (('https:' == document.location.protocol) ? 'https://' : 'http://'); </script>"}
  • 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-18T22:27:45+00:00Added an answer on June 18, 2026 at 10:27 pm

    Is there a way to achieve what I want without resorting to html5 or jsonp. Can I somehow still get a response with ajax?

    You’re not using ajax. You’re doing JSONP (or something functionally identical).

    The response from http://www.eya.com/wordpress/register/?callback=callbackF&ver=2.5&url= must be a valid script fragment. From your error message, it isn’t. (What I get back when I try it is a 404 page, which would tend to be an invalid script.)


    Update: Your response is a valid JSON object, but not a valid JavaScript fragment, because the opening { looks like the beginning of a block rather than the beginning of an object literal to the parser, because it doesn’t appear where an expression is expected.

    To make it work the way you describe (which is JSONP), the response must wrap that object in the call to the callback named in the URL, like this:

    callbackF({ "userid":"24645", "token":"40A164ECA4DE4A4F", "script":"<script type='text/javascript'>var dbnwid=16211; var dbnpid=23113; var dbnwebid=19459; var dbnlayout=21; var dbncolor='#000000'; var dbntitlefontsize='14'; var dbnbgcolortype=1; var dbnheader='You might enjoy reading:'; var dbnremindercolor=2; var dbn_protocol = (('https:' == document.location.protocol) ? 'https://' : 'http://'); </script>"})
    

    More about JSONP here.

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

Sidebar

Related Questions

I'm trying to make an ajax request recursively upon each success response that is
I'm trying to make a request to a page, and save the cookie that
I am trying to make a request to a webpage that requires cookies. I'm
I am trying to make a request to an inbound http endpoint that uses
I'm trying to make a http request. The code looks like this: NSString *urlString
I am trying to make a request to the yahoo wheather forcast like this
Trying to make a cross protocol, same domain request from https to http. I
I'm trying to make a request via SSL. The certificate is already installed on
I'm trying to make this request to the RunKeeper API : GET /user HTTP/1.1
I'm trying to make a request/reply section in my project. I want to achieve

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.