Home Web Front-end JS Tutorial Solution to the problem of jquery attr setting src containing & (macro) symbol_jquery

Solution to the problem of jquery attr setting src containing & (macro) symbol_jquery

May 16, 2016 pm 06:04 PM
symbol

Problem description:

The html code is as follows:



I use jquery's attr method to set the src attribute of the iframe

$ ("#addOrUpdateIframe").attr("src", "http://blog.jb51.net/search.aspx?key=400");//You can click the link to view the effect. Note the number of pages (display the first page of data) )

No problem, I got the results I wanted, but the following address lost all the parameters after the key (the parameters in red font were not retrieved)

$("# addOrUpdateIframe").attr("src", "http://blog.jb51.net/search.aspx?key=400&page=2");//You can click the link to view the effect. Pay attention to the number of pages (display the second page of data)


I was depressed and felt very strange, so I used firebug to check the modified value. The problem was found. jquery changed the above address into:

http:// blog.jb51.net/search.aspx?key=400&page=2//You can click the link to view the effect. Pay attention to the page number (display the first page of data)

Depressed. . . . . . . . . . . . . . . .

I have been looking for it for a long time but I still can’t find it. If this problem is solved, why did he change the & in the address to &? I’m a bit confused about

Problem solution:

accidentally added

$("#addOrUpdateIframe").attr("src", "http://blog .jb51.net/search.aspx?key=400&page=2");//You can click the link to view the effect. Pay attention to the page number (display the first page of data)

is changed to

$( "#addOrUpdateIframe").attr("src", 'http://blog.jb51.net/search.aspx?key=400&page=2');//You can click the link to view the effect. Note the page number (display the second page Data)

Pay attention to the gray background, change the double quotes to single quotes, and the problem is solved.

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)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months 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)

iOS 17: How to use emojis as stickers in Messages iOS 17: How to use emojis as stickers in Messages Sep 18, 2023 pm 05:13 PM

In iOS17, Apple has added several new features to its Messages app to make communicating with other Apple users more creative and fun. One of the features is the ability to use emojis as stickers. Stickers have been around in the Messages app for years, but so far, they haven't changed much. This is because in iOS17, Apple treats all standard emojis as stickers, allowing them to be used in the same way as actual stickers. This essentially means you're no longer limited to inserting them into conversations. Now you can also drag them anywhere on the message bubble. You can even stack them on top of each other to create little emoji scenes. The following steps show you how it works in iOS17

How to remove commonly used emojis from the keyboard on iPhone How to remove commonly used emojis from the keyboard on iPhone Jun 28, 2023 pm 12:50 PM

Today, expressing emotions using emojis is the easiest way to communicate with others. We tend to use a few different types of emojis when typing text messages or forwarding in social media apps on iPhone. Since the iPhone keeps track of the emojis we have used recently, it will display these under the "Frequently Used" tab on the iPhone keyboard. This is a plus for most young people who spend a lot of time typing, but some iPhone users find it annoying and want those commonly used emojis cleared from the keyboard. After digging deeper, we found that this issue can be cleared by resetting the keyboard dictionary on your iPhone. In this article, we will explain how to remove

How to type symbols on computer How to type symbols on computer Apr 03, 2024 pm 03:03 PM

1. Use the special character keys on the keyboard: Most computer keyboards have some special character keys, such as exclamation mark, question mark, equal sign, etc. Users can enter the corresponding symbols by pressing the Shift key plus these special character keys. 2. Use the special character panel: Some operating systems and text editing software provide special character panels, which can easily select and insert various symbols. Users can look for the special characters option in system settings or in the menu of their text editing software, then browse and select the desired symbol. 3. Use symbol input method: Some input method software provides symbols

A closer look at the key symbols in PHP arrays: What does => mean? A closer look at the key symbols in PHP arrays: What does => mean? Mar 13, 2024 pm 04:45 PM

Title: A closer look at the key symbols in PHP arrays: What does => mean? In PHP programming, arrays are a very commonly used data structure, and in the definition and use of arrays, we often encounter a key symbol "=>". This symbol is used in PHP to represent the relationship between key-value pairs in an associative array. In this article, we will delve into the specific meaning of the "=>" symbol in PHP arrays and demonstrate its usage through code examples. 1.The meaning of “=>” symbol in PHP

How to input the inequality symbol in PPT How to input the inequality symbol in PPT Mar 26, 2024 pm 03:21 PM

1. Open the PPT software and enter the operation interface. 2. Find the insert option in this interface. 3. Click the Insert option and find the Special Symbol option in its sub-menu. 4. Click the Special Symbol option to pop up the Insert Special Symbol dialog box. 5. Find the mathematical symbol option in this dialog box. 6. Click on the Mathematical Symbol option and find the Not equal to symbol option within it. 7. Click this option and you can see that our inequality symbol has been entered in the input area.

How to get the sign of an integer in Python? How to get the sign of an integer in Python? Sep 18, 2023 pm 09:53 PM

Introduction Python integers are one of the major data types used in almost all major mathematical and logical operations. In Python, an integer is zero, a positive or negative integer, has no decimal part, and has infinite precision. They can be represented in binary, octal and hexadecimal values. In this article, we will learn how to get the sign of an integer. Methods used Use a simple mathematical comparison with zero Use the copysign() function of the math module Use the numpy.sign() function Use the abs() function to create a method Method 1: Use a mathematical comparison with zero We can use the basics of positive and negative numbers Mathematical definition to find the sign of a given integer. We use a basic if-else structure to determine the sign of a number. grammar

Master the role of the $ symbol in jQuery Master the role of the $ symbol in jQuery Feb 26, 2024 pm 07:57 PM

In front-end development, jQuery is a popular JavaScript library that is widely used to simplify DOM manipulation and event handling. In jQuery, the most representative symbol is the $ symbol. This article will combine specific code examples to deeply explore the importance of the $ symbol in jQuery. 1. The origin and role of the $ symbol. jQuery is a js library created by John Resig. It aims to simplify the process of operating JavaScript and HTML documents and uses many functions.

PHP string processing: a practical way to remove symbols PHP string processing: a practical way to remove symbols Mar 24, 2024 pm 02:54 PM

PHP, as a popular server-side scripting language, is widely used to develop web applications. When processing strings, you often encounter situations where you need to remove specific symbols. This article will introduce some practical methods and specific code examples to help readers better handle symbols in strings. 1. Use the str_replace() function to remove specific symbols

See all articles