Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.ajax({
- type: "GET",
- url: "http://saskatchewan.univ-ubs.fr:8080/SASStoredProcess/do?_username=DARTIES3-2012&_password=P@ssw0rd&_program=%2FUtilisateurs%2FDARTIES3-2012%2FMon+dossier%2Fanalyse_dc&annee=2012&ind=V&_action=execute",
- dataType: "jsonp",
- }).success( function( data ) {
- $( 'div.ajax-field' ).html( data );
- });
- $.ajaxPrefilter( function (options) {
- if (options.crossDomain && jQuery.support.cors) {
- var http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
- options.url = http + '//cors-anywhere.herokuapp.com/' + options.url;
- //options.url = "http://cors.corsproxy.io/url=" + options.url;
- }
- });
- $.get(
- 'http://en.wikipedia.org/wiki/Cross-origin_resource_sharing',
- function (response) {
- console.log("> ", response);
- $("#viewer").html(response);
- });
- // It is good specify the charset you expect.
- // You can use the charset you want instead of utf-8.
- // See details for scriptCharset and contentType options:
- // http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings
- $.ajaxSetup({
- scriptCharset: "utf-8", //or "ISO-8859-1"
- contentType: "application/json; charset=utf-8"
- });
- $.getJSON('http://whateverorigin.org/get?url=' +
- encodeURIComponent('http://google.com') + '&callback=?',
- function (data) {
- console.log("> ", data);
- //If the expected response is text/plain
- $("#viewer").html(data.contents);
- //If the expected response is JSON
- //var response = $.parseJSON(data.contents);
- });
- $.get(
- 'http://www.corsproxy.com/' +
- 'en.wikipedia.org/wiki/Cross-origin_resource_sharing',
- function (response) {
- console.log("> ", response);
- $("#viewer").html(response);
- });
- $.ajax({
- crossOrigin: true,
- url: url,
- success: function(data) {
- console.log(data);
- }
- });
- // Create a listener.
- HttpListener listener = new HttpListener();
- // Add the prefixes.
- //foreach (string s in prefixes)
- //{
- // listener.Prefixes.Add(s);
- //}
- listener.Prefixes.Add("http://*:1234/"); // accept connections from everywhere,
- //because the printer is accessible only within the LAN (no portforwarding)
- listener.Start();
- Console.WriteLine("Listening...");
- // Note: The GetContext method blocks while waiting for a request.
- HttpListenerContext context;
- string urlForRequest = "";
- HttpWebRequest requestForPage = null;
- HttpWebResponse responseForPage = null;
- string responseForPageAsString = "";
- while (true)
- {
- context = listener.GetContext();
- HttpListenerRequest request = context.Request;
- urlForRequest = request.RawUrl.Substring(1, request.RawUrl.Length - 1); // remove the slash, which separates the portNumber from the arg sent
- Console.WriteLine(urlForRequest);
- //Request for the html page:
- requestForPage = (HttpWebRequest)WebRequest.Create(urlForRequest);
- responseForPage = (HttpWebResponse)requestForPage.GetResponse();
- responseForPageAsString = new StreamReader(responseForPage.GetResponseStream()).ReadToEnd();
- // Obtain a response object.
- HttpListenerResponse response = context.Response;
- // Send back the response.
- byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseForPageAsString);
- // Get a response stream and write the response to it.
- response.ContentLength64 = buffer.Length;
- response.AddHeader("Access-Control-Allow-Origin", "*"); // the magic header in action ;-D
- System.IO.Stream output = response.OutputStream;
- output.Write(buffer, 0, buffer.Length);
- // You must close the output stream.
- output.Close();
- //listener.Stop();
- $.ajax({
- type: 'POST',
- url: 'http://LAN_IP:1234/http://google.com',
- success: function (data) {
- console.log("Success: " + data);
- },
- error: function (e) {
- alert("Error: " + e);
- console.log("Error: " + e);
- }
- });
- var req = new XMLHttpRequest();
- req.open('GET', 'http://localhost/get_url_content.php',false);
- if(req.status == 200) {
- alert(req.responseText);
- }
- $('.div_class').load('http://en.wikipedia.org/wiki/Cross-origin_resource_sharing #toctitle');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement