这个原型[ajax.Request]代码中的问题在哪里?

时间:2010-09-24 14:21:10

标签: javascript forms post prototypejs ajax.request

  function sendM() {
new Ajax.Request("sendm.html", 
{ 
method: 'post', 
postBody: 'text='+ $F('text') +'&sub='+ $F('subject') +'&sname='+ $F('name') +'&sfmail='+ $F('email') +'to='+ $F('to'),
onLoading:showLoad,    
onComplete: showResponse
});
}
function showLoad(){
    $('dresult').innerHTML= "מבצע את הפעולה &nbsp;&nbsp;<br /><br />";
}

function showResponse(req){
    $('dresult').innerHTML= req.responseText;
}

hTML表单代码:

<form id="sfunc" name="sfunc" onsubmit="return false;">
                              שם                                                         דוא"ל                                                         יעד                                       1             2             3                                                         נושא                                                         הודעה                                                                                             
                                                                                     

1 个答案:

答案 0 :(得分:-1)

您尝试在初始化之前使用showLoad和showResponse。将showLoad和showResponse的函数定义移到Ajax请求之上。

为了将来参考,请注意,Ajax处理程序中发生的任何错误都不会在浏览器错误控制台中打印出错误。您必须在处理程序中创建断点来解决问题。使用像Firefox的Firebug插件这样的调试器。