douxian3170 2015-10-30 22:20
浏览 58

Prestashop Ajax呼叫未处理

The code was utilizing require_once and it wasn't executing, by removing these and debugging the problem was solved

Changed required to include_once so

include_once(dirname(__FILE__).'../../../../config/config.inc.php'); include_once(dirname(__FILE__).'../../../../init.php');

are working, but I still cannot access database files

old edit Ok so

`if (!defined('_PS_VERSION_'))
    echo('no ps ');`

is echoing "no" into the return call of my ajax call, I have tried require_once(dirname(FILE).'../mymodule.php'); and it gave me a internal server error 500 in the console.

Every type of require_once call I've tried has given the same error, including direct hardcoded directories, url links, different files, files in the same directory, files in c and I've had no luck. older EDIT

Ok, $_GET is showing the data is correctly passed to the ajax, the require_once was not working, so the ajax.php was not executing at all.

However, now Tools::getValue is not working, I have not tried to edit the DB but I don't think it will work since Tools::getValue is causing an error

END OF EDIT

Here's my ajax call, where urlvariable is pointing to http://myserverladidah/ajax.php and there's a bunch of variables to go along with it ?data= (some data) &moreData= (some more data)

It's redirecting to the correct controller, so the page redirect is fine, but nothing is happening in the ajax.php, I've cut the ajax down to just writing a hard-coded statement to insert something into the database but there's nothing happening.

jQuery.get(urlvariable, function (data) {
            window.location = 'index.php?controller=backendadminpage';
        });

I've double checked the url that I'm calling, and all the variables are checking out, but I just can't get these javascript variables into the database.

Sorry it was insufficient information, I hope this helps // more information

var x = myFunction.getX;
var y = myFunction.getY;
var z = myFunction.getZ;

var urlvariable = '{$server}/modules/mymodule/ajax.php?x=' + x + '&y=' + y + '&z=' + z;

//ajax.php file

<?php
require_once('../myModule.php');

$sql = 'INSERT INTO `ps_my_table` (`name`) VALUES (`a`)';
Db::getInstance()->execute($sql);

//previously php file tried to get values using tools, but since nothing was happening I deleted the code and tried the above

ps_my_table (name) VALUES (' . Tools::getValue['x'] .')';

//variables are dumping properly in javascript with

console.log(x);
console.log(y);
console.log(z);

//outputting

1
2
3
  • 写回答

1条回答 默认 最新

  • dongshi9526 2015-11-02 15:03
    关注

    The code was utilizing require_once and it wasn't executing, by removing these and debugging the problem was solved.

    The ajax script can successfully use $_GET to manipulate the data as required.

    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致