Код: Выделить всё
< /code>
Я знаю, что эта проблема может быть решена Ajax. Теперь я пытаюсь реализовать методы AJAX, как это приведено на веб -сайте W3Schools.function change( el)
{
if ( el.value == "ON" )
{
el.value = "OFF";
el.style.backgroundColor = "#ff3333"; /* Red */
}
else
{
el.value = "ON";
el.style.backgroundColor = "#4CAF50"; /* Green*/
} // works till here like expected.
// this proves that HTML code communicates with this function
// and also there's a value in 'el.value' which is received from the
// value attribute of the input tag.
var xmlhttp = new XMLHttpRequest(); // create a xmlhttp object
xmlhttp.onreadystatechange = function() // create a function to
// execute when the server response is ready
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{ // empty
}
}
//I just want to send the value in 'el.value' to postform.php file
//In 'postforn.php' file i want to display the received value.
xmlhttp.open("GET", "postform.php?switch=" + el.value, true)
xmlhttp.send();
}
< /code>
Вот код PHP, который я пытаюсь выполнить: < /p>
Подробнее здесь: https://stackoverflow.com/questions/375 ... loading-th
Мобильная версия