duandou8120 2011-06-16 10:47
浏览 38

jQuery .ajax()方法

I am new to the jQuery AJAX ajax() Method. I have successfully created the function AddATeacher() which gets called because all the alert messages do popup. However the ajax() Method inside the function does not work. I know this because the addATeacherInsert.php does not load.

I got it to work under firefox, but not on chrome. However it only works in firefox when I have the alert message at the end of the code: alert ("Exiting myJQFunctions...");, otherwise it stops working all together. I would like it to work when I comment out the alert message at the end of the file. How can I solve this?

function AddATeachers()
{
    var tFirstName     = $('#teachers_first_name').attr('value');  
    var tLastName     = $('#teachers_surname').attr('value');  

    alert ("Entering myJQFunctions...");
    alert ("Teachers first name is: " + tFirstName);

    $.ajax({  
       type: "GET",  
       url: "../pgs/addATeacherInsert.php", 
       data: "tFirstName="+ tFirstName +"&tLastName="+ tLastName,  
       success: function(html){$("#Ajax_response").html(html);}  
    });  

    // works well under firefox but shows alert
    // doesnt work at all if commented out.
    alert ("Exiting myJQFunctions...");    
}
  • 写回答

3条回答 默认 最新

  • doukuipai8544 2011-06-16 11:01
    关注

    You could use the jQuery GET method

    function AddATeachers() { 
    .get('url/phpPage.php', {tFirstName: $('#teachers_first_name').attr('value'), tLastName: $('#teachers_surname').attr('value')}, function(returnData){
    $("#Ajax_response").html(returnData);
    });
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100