使用jquery ajax从php函数更新数据

i have two division in my file say form.php....

Division A

All data from table abc (here i am getting data from db)


Division B

Some fields

Add Data (Button) will store data in table abc through ajax using following code (It's storing data)


Now my problem is when i add data in Division B i want to update Division A with newly added data through ajax...

for that i am trying this code but i am getting console error say Uncaught SyntaxError: Unexpected identifier

  $("#addField").click(function(){ 
        label=$("#ilabel").val();
        name=$("#iname").val();
        type=$("#itype").val();
        $.ajax({
            url : 'ajax.php', // this is adding **division B** data in database
            data : {reqtype:'insert',label:label,name:name,type:type},
            type: 'POST',
            success : function(data){ 
                $("#showform").html('<?php echo $d->fetchform() ?>'); // here i am trying to update Division A on success but getting error
            }
        })
    })

$d->fetchform() is giving all the formatted data from the table abc...

i don't know how to deal with this problem.. can you please suggest me how can i do it... (i want to do it through ajax only)

Thanks in advance..

You are trying to output server-side code (i.e. the PHP echo code) via client-side. This will never work (you'll just end up outputting the whole string inside the html() call as-is, without getting it parsed).

You should try putting the php fetchForm() call in a web service, or another file on your server, and get the contents of that via AJAX again.