我如何发送数组到PHP通过AJAX? [英] How can I send an array to php through ajax?

查看:134
本文介绍了我如何发送数组到PHP通过AJAX?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想送构建在JavaScript中使用的多项选择中选择值的数组。有没有办法使用Ajax这个数组发送到PHP脚本?

I want to send an array constructed in javascript with the selected values of a multiple select. Is there a way to send this array to a php script using ajax?

推荐答案

您可以回发到你的服务器,XML或JSON。你的JavaScript将要兴建后,它在XML的情况下,将要求您在JavaScript创建它。 JSON不仅lighterweight而且容易使在JavaScript。请查看 JSON-PHP 解析JSON。

You can post back to your server with XML or JSON. Your javascript will have to construct the post, which in the case of XML would require you to create it in javascript. JSON is not only lighterweight but easier to make in javascript. Check out JSON-PHP for parsing JSON.

您可能想看看在PHP 创建JSON数据。

You might want to take a look at Creating JSON Data in PHP

这篇关于我如何发送数组到PHP通过AJAX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆