0

DEMO

I am trying to summarise a text by posting data on to a website which provide that feature i have used two approaches but both failed miserably

  1. At first i tried to load it in an iframe and tried to access contents inside it but it shows some browser restriction error

Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://fiddle.jshell.net" from accessing a frame with origin "http://autosummarizer.com". Protocols, domains, and ports must match.

  1. Then i tried to send a post request to the domain that to failed here is the website which i am trying to post data to but receive following error

XMLHttpRequest cannot load http://autosummarizer.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://fiddle.jshell.net' is therefore not allowed access.

Jquery

var v='Banking Jobs, recruitment in Thiruvananthapuram, Kerala | Indeed ...Jobs 1 - 10 of 60 ... 60 Banking Jobs available in Thiruvananthapuram, Kerala on Indeed.com. ... Testhouse India Private Limited - Thiruvananthapuram, Kerala ... www.indeed.co.in';

alert($('iframe').contents().find("h2").html());

$.post( "http://autosummarizer.com",{ text: v,submit:"Summarize" },{dataType : "jsonp" } ,function( data ) {
  alert( data );
});
codefreaK
  • 3,584
  • 5
  • 34
  • 65

1 Answers1

0

The website you're trying to add to your iframe element must enable CORS. That Auto Summarizer apparently has an API, I suggest you get in touch with them to get access to their API and use this service properly.

Bruno Pessanha
  • 2,874
  • 4
  • 24
  • 35