PHP方面的,急求!
本人用Ajax在视图页面的一个ID为d_content的DIV中返回了一些数据,我想获取这些数据中的一个DIV的 ID,以便用jquery设置它的样式,但是怎么都拿不到这个ID,视图源代码中也没Ajax返回的数据的代码,请问这要怎么解决?
回复讨论(解决方案)
具体查看下ajax是否返回div数据成功
代码贴出来看看
ajax 回调函数中
$('#d_content').find('#指定id')....
ajax返回的数据已经显示出来了,还有那个find()函数我也用了 ,都不行,对了,忘记说了一点,Ajax返回的值是在jquery的html()里面的,变成innerHTML也还取不到。。。代码不能外漏啊 ,真抱歉
你不能弄个测试代码吗?
你返回的内容是什么格式的?
我用AJAX返回的dataType是html的
$("#sel_list").change(function(){
$.get("/shop/showphotos", {album_id:$("#sel_list").val()}, function(dt){
document.getElementById("d_content").innerHTML = dt;
},"html");
});
1 |
|
相对完整的测试例
1 |
|
还是不行,我想要鼠标悬浮的样式 按你的办法走了 还是没反映,就取不到那个ID JS文件路径什么的肯定对 因为这个JS文件里还有别的 ,都可以,就这个取不到
你不肯给真实的代码,给的测试代码由不能反映真实情况
你说该怎么办?
我只能提醒你:id 必须是唯一的
这个就是真实的AJAX代码,还有,我想取的是ID下的一个Class。。。 真的很谢谢你。我在firebug里看到那些AJAX返回的代码了 ,都没问题。。。。
这是phtml代码的,用的Zend框架 返回的数据都在这里面。。。
这是firebug下看到的返回的数据 就取那个 class="pic_box1"
$('.pic_box1') 得到的是一个数组。
你还需要在each 中单独处理,当然整体设置也是可以的
麻烦你帮我解决下好吗,我不知道那个each怎么用的
我都不知道你想做什么,怎么帮你解决?
对了,我之前用的就是这个代码,$()按你说的取的也是一个数组,但是没有each处理也能出效果,那些数据是在HTML页面的,这个是因为现在这些数据是AJAX返回的么?
现在这个AJAX返回的是 一些图片,这些图片由DIV包着,设margin:5px;我就想设置鼠标放在这些图片上的时候,有那种选中的效果,比如让DIV的border显示并且加个背景颜色。。。
我都不知道你想做什么,怎么帮你解决?
解决了,方法是对的,但是我忽略 ajax的同步异步请求了,这个东西在这需要同步一下的
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.
