来自PHP文件的Ajax回调

I'm trying to pass two number and check if their product is true or false. I can see call made successfully in network tab and when i click that link, output is correct to. But i m stuck at retrieving that result. It doesn't show anything in data1.

function call(){
    console.log(fun);
$.ajax({
  url: "http://localhost/mt2/checkanswer.php",
  dataType: "jsonp",
  type: "POST",
           //window.alert("what");
  data: {
    num1:2,
      num2:2,
      answer:5

  },
  success: function( data1 ) {
     console.log(data1);
    $( "#timeDiv" ).html( "<strong>" + data1 + "</strong><br>");
  }

<?php

  // get two numbers and the answer (their product) and return true or false if the answer is correct or not. 
  // using this as an api call, return json data
  // calling <your host>/checkanswer.php?num1=4&num2=5&answer=20 will return true
  // calling <your host>/checkanswer.php?num1=4&num2=5&answer=21 will return false

  if(isset($_GET['num1']) && isset($_GET['num2']) && isset($_GET['answer']) && is_numeric($_GET['num1']) && is_numeric($_GET['num2']) && is_numeric($_GET['answer'])) {

    $product = $_GET["num1"] * $_GET["num2"];

    if ($product === intval($_GET['answer'])) {
      $result = true;
    } else {
      $result = false;
    }
    header('Content-type: application/json');
    echo json_encode($result);

  } 
?>

https://drive.google.com/open?id=1ocF344ZxG3HXJR0WQha1kOoVM9bCepnI "console"

The issue is your Javascript is submitting the data via JS as a post request and your PHP is looking for a get request.

if(isset($_GET['num1']) && isset($_GET['num2']) && isset($_GET['answer']) && is_numeric($_GET['num1']) && is_numeric($_GET['num2']) && is_numeric($_GET['answer'])) {
 ..
}

So either change method: 'POST' to method: 'GET' or change $_GET[..] to $_POST[..].

Also that's one wild if statement. You could break it up so it's not so long and isn't as hard to read. This also allows you to add some additional information based on where your code 'fails.'

if ( isset($_GET['num1'], $_GET['num2'], $_GET['answer']) ) {

  if ( !is_numeric([$_GET['num1'], $_GET['num2'], $_GET['answer']]) ) {
    // Our numbers aren't numeric!
    $message = 'Not all variables are numeric';
    $result = false;
  } else {
    $message = 'We did it!';
    $result = $_GET['num1'] + $_GET['num2'] == $_GET['answer'];
  }

} else {
  // We didn't have all of our request params passed!
  $message = 'We didn\'t have all our variables';
  $result = false;
}

header('Content-type: application/json');
echo json_encode([ 'message' => $message, 'result' => $result]);

Edit

Based on epascarello's comment remove dataType: 'jsonp'.