【发布时间】:2023-04-11 07:31:01
【问题描述】:
我正在尝试从多个 div 中获取数据并使用 ajax 将所有数据发布到 PHP 函数
<div id="1" class="structure_box span12 strow_0 ">
<div class="structuretmp_name span6">
<span>name</span>
</div>
<div id="structuretmp_list" class="structuretmp_list span6">
<select id="jform_structuretmp" class="chzn-done" name="jform[structuretmp]" style="display: none;">
<div id="jform_structuretmp_chzn" class="chzn-container chzn-container-single" style="width: 220px;"
title="">
<a class="chzn-single" tabindex="-1">
<span>Age</span>
<div>
<div class="chzn-drop">
</div>
...
//several item like this
我需要这样的东西将 php 文件作为 json 或对象传递 姓名:姓名,年龄:生日,,, 例如,名称是一个跨度,名称是从所选插件中选择的字段
编辑:
脚本
$(document).ready(function(){
$("#submit").click(function(){
// AJAX Code To Submit Form.
$.ajax({
type: "POST",
url: "ajaxsubmit.php",
data: {
id: id,
org_name: org_name,
...
},
cache: false,
success: function(result){
alert(result);
});
return false;
});
});
【问题讨论】:
-
这获得了投票?你试过什么?
-
请添加更多详细信息和一些现有代码并指定您的问题:您要发送哪些数据?你需要组织/转换它吗?你的 PHP 看起来怎么样?
-
所以最后你想从你的 html 代码发布一个包含 id 等的 json 对象到一个 php 站点,你想发送所有对象还是只发送特定对象?你想发布什么信息?所有属性和 innerText 或只是一些属性?没有内部文本内部文本?什么是 org_name?