0

Here is the partial code from the remove PHP file:

if($action == 'trackings_get') {
 $result = $trackings->get(getCourierSlugByID($GLOBALS['tracking_id']), $GLOBALS['tracking_id']);
 $result_history = $result['data']['tracking']['checkpoints'];
 echo json_encode($result_history);
 // debugging
 //pretty_print($result_history);
}

Here is the JS from the remote site i am trying to call the data for:

$.ajax({
 url: '/login/tracking.php',
 type: 'POST', 
 dataType: "json",
 data: {
 action: action,
 tracking_id: tracking_id
 }, 
 success: function(json){ 
 //debug
 alert(JSON.stringify(json));
 }
});
halfer
20.2k20 gold badges111 silver badges208 bronze badges
asked Dec 7, 2017 at 5:54
3
  • convert alert(JSON.stringify(json)); to console.log(json); and see what is coming in console. Now you can use that json (if output is coming fine.) . You used dataType: "json", so no need of JSON.stringify() Commented Dec 7, 2017 at 5:56
  • I tried that but nothing was returned, and look in network i see the POST but no result, if i change to GET i see the returned array though but not sure right way to get this data and handle it... Commented Dec 7, 2017 at 6:00
  • change POST to GET and then try to use the data according to your wish Commented Dec 7, 2017 at 6:00

2 Answers 2

1

try this

function test(){
$.ajax({
 url: 'url',
 type: 'POST', 
 dataType: "json",
 data: {
 action: action,
 tracking_id: tracking_id
 }, 
 success: function(json){ 
 }
});
}
answered Dec 7, 2017 at 17:14
Sign up to request clarification or add additional context in comments.

Comments

1

i try this code in inspect element in this page https://tracking.ambientlounge.com/

function test(){
$.ajax({
 url: 'your url',
 type: 'POST', 
 dataType: "json",
 data: {
 action: "action",
 tracking_id: "tracking_id"
 }, 
 success: function(json){ 
 //debug
 console.log(json);
 }
});
}

result is array . dont need JSON.stringify .

answered Dec 7, 2017 at 6:09

4 Comments

ali zarei you used hardcoded value in url and hens POST method and data sending become useless. That's not the right way to do so
it is a sample only !!
then it's wrong way to giving sample. This sample will serve future visitors too. So it will misguide them as well.
Yes I agree, can you please modify this Answer as dont want URLs or screenshots to this system. I have adjusted the questiont o remove the POST URL to remove this but please adjust your reply.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.