Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial ecshop Ajax.call问题

ecshop Ajax.call问题

Jun 20, 2016 pm 12:43 PM

index.dwt文件里面写
Ajax.call('index.php', 'act=aaaa&items=' +items, bbbb, 'GET', 'json') //成功

category.dwt文件里面写
Ajax.call('category.php', 'act=aaaa&items=' +items, bbbb, 'GET', 'json') //不成功
Ajax.call('index.php', 'act=aaaa&items=' +items, bbbb, 'GET', 'json') //成功
Ajax.call('category.php', 'intro=aaaa&items=' +items, bbbb, 'GET', 'json') //成功

brand.dwt文件里面写
Ajax.call('index.php', 'act=aaaa&items=' +items, bbbb, 'GET', 'json') //成功
Ajax.call('brand.php', 'act=aaaa&items=' +items, bbbb, 'GET', 'json') //不成功

.php 里面的代码都是一样的,我试了下,好像就只有index页面是可以的,其他的页面,如果也给路径到index.php也是可以成功,但是给到自己的文件(如:brand.dwt里面给到brand.php)就不行了,报错Uncaught transport.js/parseResult() error: can't parse to JSON.
我看了下首页需要调用的js文件,其他页面也是有调用的。上面报错的网上说是jquery冲突的,那为什么首页就可以了


回复讨论(解决方案)

Uncaught transport.js/parseResult() error: can't parse to JSON.
是说 json 格式错误,不能解析

显然你在输出 json 串时还输出了什么东西

我用Google浏览器上面的工具查看,我触发后items是有值的,但是下面还有一串数字的,这串数字应该没影响的。触发后没有进到PHP文件里,能进到index.php里面,但是不能进入到其他PHP文件里的,那index.php文件里那句是解析JSON格式的?

我们只能就事论事,你连一点有价值的信息都不提供。怎么能指望解决问题呢?

如果你自己能分析出问题的所在,好像也没有在这里发帖的必要了吧

为啥要用他内置的呢?不能直接用jquery的去写一个么?

抱歉!也许是这个问题搞得我有点心急的,没有把提供全面的信息就来问大家了,这里给大家道歉了

js文件
function aaaa(id)
{
//alert(id);
//Ajax.call('brand.php', 'act=bbbb&id=' + id, cccc, 'GET', 'JSON');
Ajax.call('index.php', 'act=bbbb&id=' + id, cccc, 'GET', 'JSON');
}

function cccc(rest)
{
alert(rest.content);
}

php 文件
$act = !empty($_GET['act']) ? $_GET['act'] : '';
if($act == 'bbbb')
{
$id = $_GET['id'];
$result = array('content' => '');
include_once('includes/cls_json.php');
    $json = new JSON;
$result['content'] = $id;
die($json->encode($result));

}
这个就是我测试的代码,我刚刚测试过的,Ajax.call里面的路径给到brand.php就不弹出,Ajax.call路径给到index.php就 正常,都是上面的这个代码

除了我说过的原因以外
你还得看你的这个项目是否为单入口项目,如果是的话 brand.php 就不能被直接访问到了

www.XXX.com/index.php可以访问到首页
www.XXX.com/brand.php可以访问到品牌页
这个是否可以说明不是单入口项目了,那除了这个方向外,还有那些可能去情况

请教  怎么解决的  我现在也遇到这个问题了   

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

Video Face Swap

Video Face Swap

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

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)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

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,

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

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.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

See all articles