javascript - Get path from parent URL (current window URL) in ajax call looped inside another ajax call -


i have php page (client.php) contains script below. script performs ajax call. upon success, executes ajax call. i'm having issue second ajax call returns request_uri "sql/adminloademail.php" not parent path "/client.php". how tell php echo parent path "/client.php" appears in current window url?

script

$.ajax({   method:'post',   url:'sql/adminaddclient.php',   data:formdata,   contenttype: false,   processdata: false,   success: function(data){     $.ajax({       type:'post',       url:'sql/adminloademail.php',       success: function(data){         $('#account_list').html(data);       }     });   } }); 

php(adminloademail.php)

$page = parse_url(filter_input(input_server, 'request_uri' , filter_sanitize_string), php_url_path); echo $page; 

you can set parent url variable , send data param.

var parenturl = window.location.href;  $.ajax({   type:'post',   url:'sql/adminaddclient.php',   data:formdata,   contenttype: false,   processdata: false,   success: function(data){     $.ajax({       type:'post',       data:{"parenturl":parenturl},       url:'sql/adminloademail.php',       success: function(data){         $('#account_list').html(data);       }     });   } }); 

also can try headers.

$headers = apache_request_headers(); if (isset($headers['referer'])) {     echo "referer: " . $headers['referer']; } 

since php 5.4.0 apache_request_headers available under fastcgi.

since php 5.5.7 apache_request_headers available in cli server.

http://php.net/manual/en/function.apache-request-headers.php


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -