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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:40:20+00:00 2026-06-01T20:40:20+00:00

I tried to make a cross domain request using jquery. this is how client

  • 0

I tried to make a cross domain request using jquery. this is how client side will looks like,

<script src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(document).ready( function(){
    $.ajax({
        type: 'GET',
        url: "http://www.xserver.com/xdomainhandler.php",
        processData: true,
        data: {
            type:"gotohell"
        },
        dataType: "json",
        success: function (data) {
            myglob=data;
            var repo=JSON.parse(myglob);
            alert(repo.type);
        },
        error : function(XMLHttpRequest, textStatus, errorThrown){
            alert('ends up in error state');

        }
    });
});
</script>  

and the server page code which receives this request will look like this:

<?php
header('Access-Control-Allow-Origin: *');  
header('Expires: ' . gmdate('r', 0));
header('Content-type: application/json');
session_cache_limiter('nocache');

$arr = array ('response'=>'success','comment'=>'test comment here','type'=>$_GET['type']);
echo json_encode($arr);
?>

But when i completed the request/response process i got nothing in the ‘repo’ variable. i checked the response using firebug and it shows response like,

{"response":"success","comment":"test comment here","type":"gotohell"}

also i checked myglob variable in DOM panel of firebug it shows,

Object { response="success", comment="test comment here", type="gotohell"}

but when i parsed the myglob to repo, it shows nothing.. where i’m going wrong. can somebody help me. 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-01T20:40:23+00:00Added an answer on June 1, 2026 at 8:40 pm

    You don’t need to parse it as jQuery parses it for yo so avoid

            var repo=JSON.parse(myglob);
    

    and just call

      alert(data.type);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to make working XHR cross domain request - I've tried 'Script Tag Hack'
I'm using the following code to make cross domain request using $.getJSON, request completed
I am using this AJAX proxy for cross-domain AJAX requests: http://www.daniweb.com/code/snippet494.html . It works
Getting this error on chrome while trying to make cross-domain requests with GWT application.
I am creating an iframe using jQuery to a cross-site URL. This works properly
I am trying to make a simple cross domain data request. After receiving the
There are several questions on Stack Overflow saying cross domain AJAX request etc will
Tried to make a little old school ajax (iframe-javascript) script. A bit of mootools
I tried to make an accordion effect with JavaScript based off this video altering
I tried to make http get request with code: String username = test\\v100; String

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.