Solved

how to use json in html cross domain

Posted on 2014-09-08
7
8 Views
Last Modified: 2016-05-18
whats the bast way to access json text files cross domain using jquery hopefully with an example
thanks geoff
0
Comment
Question by:hyperaccess
  • 3
  • 2
7 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40310733
With jquery ?
You can't really, you need help of a server to create a proxy.
So this server/proxy load the content for you
0
 

Author Comment

by:hyperaccess
ID: 40310740
what about using java ajax or using pjson
thanks geoff
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 250 total points
ID: 40310746
what is java ajax?
if you're talking about jsonp, you can only load a javascript script with.
<script>functionname({"text":"your file text content in this string"})</script>

If you are able to send this with te right content-type application/json you're done else forget it
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:hyperaccess
ID: 40310763
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40310765
yes this is what I'm yalked about in my previous post
0
 
LVL 4

Assisted Solution

by:Jim Riddles
Jim Riddles earned 250 total points
ID: 40312192
You can also set your script that returns your JSON data to set the access-control-allow-origin header.  With that set you can allow a page on a different domain to access your data.

In PHP you would add something like this to the top of your script:

header('Content-type: application/json');
header('access-control-allow-origin: http://yoursite.com');
header('access-control-allow-origin: https://subdomain.yoursite.com');

Open in new window


Replace the URLs with the domains that you want to allow access to the data.  Note: You may see examples that show an * in place of the URL...never use it, since it allows access from any host.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now