duanlanzhi5509 2014-08-22 12:35
浏览 18

FORM DATA使用ajax发布到PHP

    $("#agent_edit_form").submit(function(event) {


            htmlForm = new FormData( this );
            htmlForm.append = $("#agent_edit_form");

            console.log(htmlForm);
            $.ajax( {
                url: 'edit_agent.php?id=<?php echo $agent_id ?>',
                type: 'POST',
                data: htmlForm,
                processData: false,
                contentType: false,
                success: function(data){
                    $("#clients_container").html(data);
                }
            } );

            event.preventDefault();
    });

PHP:

<?php 

if(isset($_GET['id'])){
$firstname = $_POST["firstname"];
$middlename = $_POST["middlename"];
$lastname = $_POST["lastname"];
$birthdate = $_POST["birthdate"];
$age = $_POST["age"];
$TIN = $_POST["TIN"];
$SSS = $_POST["SSS"];
$email = $_POST["email"];
$telno = $_POST["telno"];
$faxno = $_POST["faxno"];
$cellno = $_POST["cellno"];
$address = $_POST["address"];
?>

im trying to use this FORMDATA to submit form data and a file(image).jpg but its not working can you check what seems to be the problem? it is returning the same data or it remains unchanged after the success.

i can see that there is data in htmlForm since im checking it using the console.log

but it seems the php is not triggering or is not receiving the posted data from ajax. (note: the JS is in the same file as the PHP code)

thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)