since a few days i try to load external html content from another domain. obviosly it is hard to access cross domain content wit
javascript ajax methodes. first i' ve tried iframes but access denied. after that I' ve tried $.ajax but all request returned zero byte data from server. here is a way that seems to work but raise an error while processing data from text to json object
i can see the server response in firebug and it requests the html data. but as i sayd i raise an error while converting to json. any chance to get raw data before jquery konversion? or maybe any other way (s) to request html data in text format from cross domain?
I'm writing this post as there are alot of questions about Cross Domain AJAX request so i'm going to give an overview of the different ways and the best practices Ok so there are 2 systems for this the key difference is how much control you have.
If you control the Requested site you can use Javascript Safe calling to that server, this is all done via a few Headers so to do this all you have to do is send some headers from the page your requesting.
The first is tell the browser that the site the AJAX call is coming from is allowed this is done with
"Access-Control-Allow-Origin: " Now this can be set to a wild card and allow all sites to access the page
"Access-Control-Allow-Origin: *" Or you can say only a set server can "Access-Control-Allow-Origin: mydomain.com"
This header allows GET requests but what if you need to post data to the site well you need to tell the browser that POST data is allowed to be sent Access-Control-Allow-Headers: GET,POST
Now we run into the problem that sending post data the browser will send the header Content-Type but your server has not told the browser its allowed to send that header so Access-Control-Allow-Methods: Content-Type Will allow the header to be sent if you wish to send any other custom headers you have to make your server tell the browser its allowed to send them this is done by adding them as a comma delimited list via the "Access-Control-Allow-Headers" header
Now if you dont have control well then your back to using a script that is local to the AJAX script then sending the data via cURL or another connection method to the remote server
I'm trying to set up a system similar to Google AdSense that allows other websites to display some HTML content from my site on theirs. I've looked at the show_ads.js file Google uses to display Ads but to be honest I've not found it easy to decipher. I've also read that using a <script> tag to load a JavaScript file from my site is simpler than trying to do do this with an AJAX request. it discusses returning JSON rather than HTML.
BTW I know I could use an iframe to achieve something similar but this won't give me the result I need because the content coming from my site will contain a link back to my site and I want the link to be registered as an inbound link to my site for SEO reasons.
Is there any way to resize an iframe dynamically to the height of its content that works cross browser and works when the iframe content is on another domain than the main page (I have access to both pages, so code can be put in either) Also, it must resize when links in the iframe are clicked (ie when a new page within the iframe is loaded)
I'm fairly new to javascript and JQuery so please bear with me. I've written a simple app using JQuery whose purpose is to select the fastest mirror site. To this end I use several $.ajax calls - one to each mirror site -and I don't do anything with the data I get from these, I only use the order in which they respond to sort the sites from fastest to slowest. I'd share the code, but really the only thing it does is call the $.ajax function and append a line in a table using the success: callback. This works perfectly fine for most browsers, except IE which throws the 'access is denied' error. I know about cross domain restrictions and understand the reasoning behind - my plan was to put my script in the 'trusted' zone and enable the required options to bypass the problem as this will be used in a controlled environment, but no matter what I try my code won't run in IE. Some of my mirror sites are indeed in a different domain. What I have trouble understanding is why all other browsers (FF, Chrome etc), with their default configuration, allow my code to run flawlessly? If the reasoning behind IE blocking this is correct, then why do others allow it? Also obviously for my purpose using a server-side proxy makes no sense as I want to test the sites from the client side, not from the server. I've also read about other work arounds such as JSONP but unfortunately the sites that I'm testing cannot support this. But once again, what I'm really wondering about is why my code works flawlessly in other browsers..
I'm new to this group, and after doing a lot (and I mean a LOT) ofsearching, I can't find an answer for my problem:I'm basically trying to do a simple $.getJSON, and the setup issimple:Firefox 3.5 MacOSX, latest jQuery (1.3.2)the json file named "myjson.json" (I've reduced its contents to itsminimum for testing purposes and it validates in JSONLint):
{"result": "true"} The javascript: $.getJSON('http://site1:8888/myjson.json', {}, function(data) { alert
I'm building a web app that provides music information (i.e. info on artists, albums, songs, etc.) and for the info source I'm using the MusicBrainz API.
Now, I'm trying to load the data from an API call and process it, with jQuery.
This is the code I'm using:
With 'queryString' being the URL string for the request, and then I'd proceed to read the data out of the 'xml' object. Fairly simple.
However, this is where problems arise. The code works flawlessly when running locally on my computer, but does not work at all when I upload everything to my web server and try to run it there. I did some reading and have discovered that AJAX calls can't be made across different domains, due to security issues.
So I've read through numerous solutions, but almost all require either something with PHP (which I have absolutely NO knowledge of) or grabbing the data in JSON format (which apparently isn't subject to the same security restrictions). However, my main problem is that the MusicBrainz API does not return data in JSON format (in fact the only format it returns is XML).
The following topic had driven me nuts for a few hours. I have been reading article after article trying to get this to work, with no luck. Lets start with what im trying to do.I am making a JS file that people can link on their webpage, and will create tooltips on links (from data from my database). Ok np. I have a php file for testing.
Code: $item = $_GET['item']; if ($item == "test") {
I have two websites. One is my mediaWiki, and one is my production site.I would like to use the mediaWiki APIand $.post() to login to the wiki and retrieve pages from the Wiki.
I need to send XML / XML string to a web service cross domain.I have a JavaScript function that creates the XML by selecting the fields on the page and formatting the values into the required XML document. The HTML page is running on the users local machine but need to send the XML to a public secure (SSL) web service (ASMX) that has one argument of type string.I have tried to come up with a solution and the only one that is currently working is JSONP with GET. But this results in the data being send as part of the query string and is in clear view, thus beingintercept-able.
I am recentlyexperiencinga problem with .ajax calling cross domain asp.net webservice. It started working fine, until the data returned from server is becoming too big and suddenly the ajax call caused errors, if i reduce the data length then the error went away. After doing some debug, i have identified the problem being the callback was inserted into the returned data.
Is it possible to use $.ajax to call an external web service directly, or do I need to write a dot net server-side wrapper to consume the web service, then call the wrapper from jQuery ?
I have attempted a direct call as shown below, which works fine in IE but generates an error in Firefox, which I presume relates to the cross-domain scripting issue.
Yet, when i made the json calls(cross domain), it just return me nothing. However, under the same domain, I got the pop-up alert and return me the relevant data. But getJSON is suppose to be feasible across all domains irrespective of the same-origin policy.
I'm trying to load google.com from a test html page using jQuery-1.5.1 but unable to do it.I've tried all the 3 methods listed but to no success.Below is the code snippet for the same & the output that I'm getting.
I trying to make a call to an external domain using $.ajax() and it WORKS, the server receives the call, but the response in firebug errors out in jquery.js line 7760. I've been beating my head at this all day and don't feel like I've made it much further.
I suspect it has something to do with the dataType or type of the request. But I've tried all kinds of things from POST to GET to JSONP in the type. For dataType, I've also tried "html", "text", "xml", "json", and even some combos of "text html" but no success.
I use $.post like so: $.post("http://mydomain.com/some/webservice", $.toJSON({ emailAddress: emailAddress }), callback, "json"); this works great..the response of the POST is a json string and that is used in the callback..now I added https: $.post("https://mydomain.com/some/webservice", $.toJSON ({ emailAddress: emailAddress }), callback, "json"); so it is now a cross domain post...in firebug I see that instead of POST'ing like in the http case..it first is sending an OPTIONS verb..why? The webservice doesn't know how to respond to that and gives a 403 forbidden...I need it to just send the POST like it did when it was on the same domain...