简体   繁体   English

在div中使用Jquery显示AJax响应

[英]Displaying AJax response with Jquery in a div

I have an ajax form that posts to a php page, which processes the form, then posts the data to mysql and then returns the data to the console. 我有一个ajax表单发布到一个php页面,它处理表单,然后将数据发布到mysql,然后将数据返回到控制台。

Since I am really new at this, I don't know how to get it to display the data on the page in a <li> or <div for each new record that is returned, just like this script does: http://www.sanwebe.com/assets/ajax-add-delete-record/ 由于我对此非常陌生,我不知道如何让它在<li><div显示页面上的数据,对于返回的每个新记录,就像这个脚本一样: http:// www.sanwebe.com/assets/ajax-add-delete-record/

This is the data that is returned in the console: 这是在控制台中返回的数据:

Object {type: "success", message: "Your message has been sent, thank you.", record: Object}
message: "Your message has been sent, thank you."
record: Object
account_number: "1234567812345678"
balance: "1234"
bank_name: "test name"
customer_id: "12345"
id: 49
monthly: "123456"

This is the current script that brings it to the console: 这是将其带到控制台的当前脚本:

jQuery(document).ready(function($) {
  $('form.quform').Quform({
    successStart: function (response) {
      console.log(response);  
    }
  }
);

Something like this: 像这样的东西:

jQuery(document).ready(function($) {
    $('form.quform').Quform({
        successStart: function (response) {
            var r = response.record;
            var html = '<li>Acct#: ' + r.account_number + '</li><li>Balance: ' + r.balance + '</li><li>Bank: ' + r.bank_name + '</li><li>Customer#: ' + r.customer_id + '</li>';
            $("#ulID").html(html);
        }
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM