function book() { var name = document.book.name.value; var avtor = document.book.avtor.value; var opis = document.book.opis.value; request.open("POST", 'chench_p.php', true); request.onreadystatechange = otvet; request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); request.send('name='+name); } function otvet () { if (request.readyState == 4) { if (request.status == 200) { var ress = request.responseText; alert (ress); } } } 

Tell me why the code does not plow? By ajax connected. (The code did not work out, but it works.)

In PHP:

 <? echo $_POST['name']; ?> 
  • And what exactly doesn’t work there? = 3 Look at the debugger - does it get the name, what does it transmit and what status of the response comes and the answer itself) Does it suddenly transmit null and take the void?) - Alexey Sonkin
  • Or can request undefined - cy6erGn0m
  • and which debugger should I use? But I wrote it correctly in html? - = <input type = "button" value = "Add" onClick = "book ();"> - Ivan
  • And where are the input and output variables? (integer, etc.) - romanzi
  • Best of all firebug (Supplement for Firefox) - Alex Silaev

1 answer 1

The book () function must not match the form name book

 "document.book." 
  • Yes, I just understood. ) THX. - Ivan