Know origin after a load

0

Very good, I'm stuck on something, to see if you can help me.

I have the following code:

$('#IdCre').load('crea.php'); 

This loads a web "Crea.php" in a div, the problem is that in crea.php I have a back button, and depending on where I do the load, it has to go to one side or another.

I explain myself in another way. When I'm on the web create.php, by hitting the previous button, I hide the current div and show another one. The problem is that the div that I have to show depends on where I charge the load.

Greetings.

    
asked by Lorenzo Martín 28.09.2017 в 17:44
source

1 answer

1

I think the quickest way to do this is to use get if you do not care about "undecided" actions.

First load load the data you want:

$('#IdCre').load('crea.php?url=orgien'); 

Where the current page will be from. It is not necessary to put the whole url, just know the name. You will already add extension etc when you try it.

Finally you collect it on the page crea.php with a get.

var url = new URL(urlactual);
var c = url.searchParams.get("url");

You load the current url. Once saved we pass it by .searchParams.get("url") where url will be the name of the parameter and variable c will finally be the desired origin.

    
answered by 28.09.2017 / 17:54
source