what should PHP file contain for Ajax

ساخت وبلاگ

Vote count: 0

I found this helpful example:
https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started
that shows how to work with data using Ajax. However, the article does not give details about what the PHP file should contain to make the example actually work. I have tried this:

<?php
$name = (isset($_POST['userName'])) ? $_POST['userName'] : 'no name';
$computedString = "Hi, " . $name;
echo json_encode($computedString);
?>

And variations thereof, to no avail. The result is a message box that says undefined. What should be in the PHP file for this example to make it work?

asked 1 min ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 367 تاريخ : پنجشنبه 31 تير 1395 ساعت: 10:49