0

I'm trying to get a processed information in a JavaScript function from another html page. But I can only get the source code.

$.ajax({
    url: 'https://example.com/',
    async: false,
    type: 'GET',
    success: function(data) {
        $('#testandodaiane').html($(data).find('#permissao').html());
        console.log('data',data);
    }
});
Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
  • Read this [post](http://stackoverflow.com/a/36432366/2813224) and if it helps upvote. – zer00ne Nov 10 '16 at 22:50
  • @zer00ne, rather mercenary of you, no? Shouldn't you just close this as a duplicate? – Heretic Monkey Nov 10 '16 at 22:53
  • @MikeMcCaughan I hate the duplicate process, but by all means you may go through the process, sir. – zer00ne Nov 10 '16 at 23:01
  • @DaianeRangel, Perhaps you can provide more information about what that other page has? For instance, what does the element with the id "permissao" contain? If it's script, then getting the `html()` from it is not going to be of any benefit. Do also note that using `async: false` has been deprecated for quite a while. – Heretic Monkey Nov 10 '16 at 23:06
  • @zer00ne I tested the solution indicated and it did not work for me. The result was the same as I had with my code. I received the source code for the page. And not the information processed. –  Nov 14 '16 at 17:18
  • @MikeMcCaughan The "permission" element contains a javascript function that tells whether a user is allowed to receive push notification in domain A. And I want to have access to that information in domain B. –  Nov 14 '16 at 17:21
  • If it's JavaScript, just move it to a file of its own, and include it in both pages, or use `$.getScript()`.... – Heretic Monkey Nov 14 '16 at 17:23
  • @MikeMcCaughan It is not a script, it is a Notification object available in the browser of the other domain. In this case it is Notification.permission. –  Nov 16 '16 at 17:11
  • Yeah, so, when you ask a question, it's really a good idea to give as much information as possible in the question... see [ask]. For instance, an example of what exactly is in the this file that you're pulling. I should note that a "Notification object" must be implemented in JavaScript or HTML's `object` element, so it's one or the other... – Heretic Monkey Nov 16 '16 at 17:24

1 Answers1

1

You can't call a javascript function in a different web page, or extract markup from a different web page. You CAN include the javascript files that the other page uses.

Seems like you're trying to build a web service. Client-side javascript is not the tool.

Xavier J
  • 4,326
  • 1
  • 14
  • 25