Home Backend Development PHP Tutorial ajax 处理php返回的json 数组有关问题

ajax 处理php返回的json 数组有关问题

Jun 13, 2016 pm 01:14 PM
info jpeg quot

ajax 处理php返回的json 数组问题
{"status":1,"info":["201209\/20120905rmyr8iZMs6.jpeg","201209\/20120905b1i8bI1C9x.jpeg","201209\/20120905Z0zFDjUF61.jpeg","201209\/20120905144fN9oLlz.jpeg"],"data":""}


这是返回的数据,info里面是一个数组,我想用js特效翻图片,我怎么获取图片的下表并判断有没有上一张或下一张图片

------解决方案--------------------
我的理解是,可以先把json数据解析成数组,然后就能得到info的数据,按照上面的格式,下标应该是数字递增的,从0开始,可以得到info数组的长度,也就能得到最后一张图片的下标了,这样是否可以判断?至于json数据解析数组,可以去网上查下,封装的库很多,常见的可以下个json.js的库(www.json.org),然后用string.parseJSON()转化。
其实像你说的这种效果,网上应该有很多示例的,可以查下~
------解决方案--------------------

JScript code

var str='{"status":1,"info":["201209\/20120905rmyr8iZMs6.jpeg","201209\/20120905b1i8bI1C9x.jpeg","201209\/20120905Z0zFDjUF61.jpeg","201209\/20120905144fN9oLlz.jpeg"],"data":""}';

var obj = eval('(' + str + ')');
alert(obj.info.length);//info长度 为4
var i=3;//测试最后一个元素
if("undefined" == typeof(obj.info[(i+1)])){
alert(321);
}else{
alert(obj.info[(i)])
} <div class="clear">
                 
              
              
        
            </div>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What image compression coding standard is jpeg? What image compression coding standard is jpeg? Dec 31, 2020 pm 02:32 PM

JPEG is a compression coding standard for continuous-tone still images; it mainly uses a joint coding method of predictive coding, discrete cosine transform and entropy coding to remove redundant images and color data. It is a lossy compression format, which can convert images Compression requires a small storage space and will cause damage to image data to a certain extent.

What format is jpeg What format is jpeg Nov 25, 2022 pm 02:46 PM

JPEG is an image format saved using a lossy compression method, and the file extension is ".jpg" or ".jpeg"; as a result of compression, the output image cannot take into account both quality and size. The JPEG format has long been the choice for storing and transmitting photographic images over the web, and almost all operating systems now have viewers that support the visualization of JPEG images, which are also often stored with the JPG extension.

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Convert JPEG image files to WBMP image files with PHP Convert JPEG image files to WBMP image files with PHP Mar 21, 2024 am 10:36 AM

This article will explain in detail about converting JPEG image files to WBMP image files with PHP. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. Introduction to converting JPEG image files to WBMP image files JPEG (Joint Photographic Experts Group) and WBMP (Wireless Bitmap) are two widely used image file formats. JPEG is used to store high-quality photos and images, while WBMP is used to store simple black-and-white images, commonly used on mobile devices and e-paper displays. This article will guide you to convert JPEG image files to WBMP image files using php. Steps to Install GD Library First, you need to install GD Library, which is a popular PHP

Are the image quality of HEIF and JPEG formats the same? Are the image quality of HEIF and JPEG formats the same? Mar 17, 2023 pm 06:17 PM

No, the picture quality in HEIF format is better. HEIC is a high-fidelity compression format that will reduce the disk or memory space occupied by images while maintaining image quality; while JPEG is a lossy image format, so the same image taken with HEIC will be smaller, but the HEIC image quality is better. As an encapsulation format, HEIF can hold much more things than JPEG; it can not only store static images and EXIF ​​information metadata, but also animations, image sequences, and even videos, audios, etc. The types of data stored must be Much richer.

Which one is clearer, jpeg or png? Which one is clearer, jpeg or png? Mar 17, 2023 am 10:43 AM

Compared with jpeg and png, the png format is clearer; because the png format is a lossless format, while the jpeg format is lossy compression, which will reduce the quality of the original image data; therefore, if you use files produced by drawing software, save When you choose to save the png format, it will be clearer than the jpeg format.

What is used to compress still images What is used to compress still images Jan 14, 2021 pm 06:36 PM

JPEG is used to compress still images. JPEG is a compression standard for continuous-tone still images, with the file extension ".jpg" or ".jpeg"; the JPEG standard is suitable for compressing still grayscale and color images. JPEG mainly uses a joint coding method of predictive coding (DPCM), discrete cosine transform (DCT) and entropy coding to remove redundant images and color data. It is a lossy compression format, which can compress images in a small storage space. Space will cause damage to image data to a certain extent.

How to turn off info information output in thinkphp5 How to turn off info information output in thinkphp5 Jun 03, 2023 am 11:49 AM

1. The function of info Before we start to close info, we need to understand its function. In the ThinkPHP5 framework, there are three main forms of info information output: displaying the currently accessed URL and request parameters; displaying debugging information such as the SQL statement execution and running time of the current page at the bottom of the page; outputting detailed error information when an execution error occurs, which is convenient Although debugging seems useful, most of the info information is not very helpful to real developers. Often, what we need is some more concise output so we can better focus on development. 2. Close info. Closing info is very simple. You only need to configure

See all articles