I
I
itpeople2018-02-19 06:28:24
JavaScript
itpeople, 2018-02-19 06:28:24

Why is the page not loading using the load() method?

Hello. Please tell me what could be the problem?
I need to load pages in a div. From the loaded page, you need to load information from a specific div.
If I load using the page address, everything works fine:

function loadPage() {
    $('#include').load('localhost/page.html +content_load');
  }


But I have several pages, so I do this and the script refuses to work:
function loadPage() {
    var url = location.href;
    var load = '#content_load';
    $('#include').load(url + load);
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2018-02-21
@vaajnur

replace location.href with location.pathname;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question