当前位置: 首页 > 工具软件 > PHP Nightrain > 使用案例 >

有数据ajax返回unf,javascript - jQuery get local time, then use AJAX to give to php - Stack Overflow...

张鹏云
2023-12-01

I need my php file f-eval.php to receive the hour time from a javascript / jQuery file time.js through $_GET and AJAX, but it isn't working. My code is as follows.

f-eval.php

$totalflightscore = 100;

// Something is wrong weather

if (isset($_GET['drizzle'])) {

$totalflightscore = $totalflightscore - 10;

}

if (isset($_GET['rain'])) {

$totalflightscore = $totalflightscore - 30;

}

if (isset($_GET['thunder'])) {

$totalflightscore = $totalflightscore - 50;

// selecting this option alone will trigger a red alert.

}

// Something is wrong wind

if ($_GET['windspeed'] > 30) {

$totalflightscore = $totalflightscore - 50;

} elseif ($_GET['windspeed' > 15]) {

$totalflightscore = $totalflightscore - 25;

} elseif ($_GET['windspeed' > 10]) {

$totalflightscore = $totalflightscore - 5;

} else {

if ($_GET['windspeed'] <= 12) {

// wind speed is less than 12 mph. do nothing.

}

}

// Something is wrong day night

if (isset($_GET['am-day'])) {

// some users of this site may hold Part 107, so do not trigger a red alert.

} else {

$totalflightscore = $totalflightscore - 20;

}

// Something is wrong airmap

if (isset($_GET['am-green'])) {

$totalflightscore = $totalflightscore + 10;

// adding because green indicates there are no controlled airspace zones nearby

}

if (isset($_GET['am-orange'])) {

$totalflightscore = $totalflightscore - 25;

// indicates you are in airport 5 mile zone, near heliport, or near tfr.

}

if (isset($_GET['am-red'])) {

$totalflightscore = $totalflightscore - 75;

// indicates you are in an airport or on a runway, in tfr, or in controlled airspace. will trigger a red alert.

}

// reCaptcha code

echo "TFS was $totalflightscore";

if ($totalflightscore <= 40) {

echo '';

} elseif ($totalflightscore <=60) {

echo '';

} elseif ($totalflightscore <=100) {

/*echo ''; */

echo "This is executing!";

if ($_GET['n']) {

echo 'I am recieveing AJAX.';

}

}

index.html

SafeFlight

#content-wrapper {

margin-left: 5%;

margin-right: 5%;

margin-top: 5%;

margin-bottom: 5%;

}

body {

width: 100%;

height: 100%;

}

@media (min-width: 992px) {

...

}

SafeFlight

Welcome to SafeFlight.

Not sure if it's safe to fly? Welcome to SafeFlight - your go-to resource for preflight planning and on-site risk assesment for flying your sUAS. Simply enter current weather conditions, and SafeFlight will notify you if it's safe to fly.


If you aren't sure whether it's legal to fly, you are able to find out using SafeFlight through an embedded version of AirMap, an open source webapp that makes airspace laws easy to understand and follow.

Legal Disclaimer

Neither SafeFlight, nor AirMap should be used exclusively to determine whether it is safe to fly. Unfroseen circumstances affecting the safety of flight can arise, and neither SafeFlight nor AirMap (or any similar apps, for that matter)

can help you with those. Please use common sense and good judgement when piloting sUAS. They are not toys and are extremely dangerous if misused or mishandled.

Get Started

How's the weather?

Clear

Overcast

Drizzle

Heavy Rain

Thunder

Is it daytime?

Day

Night

Go to this page and move to the area that your flight will be taking place. Then, look at the top left for the color of the "Warning" symbol. (triangle with "!") Please record that color below.

Green

Yellow

Orange

Red

Calculate Conditions

time.js

$(document).ready(function() {

var d = new Date();

var n = d.getHours();

alert("jQuery loaded!");

function ajax() {

$.ajax({

type: 'GET',

url: 'https://apps.roen.us/safeflight/beta/f-eval.php',

data: 'time=' + n

})

}

})

 类似资料: