I added a new button in detailviews of a module, having the attribute onClick="genReg(name, type)".
I created this function in a .js file. This function (genReg(name, type)) send the variables to a PHP file, generateReg.php, using JSON.
The file is in *module_name* folder. In this PHP file I try to create a new object of modules Reglement (it's a custom module) and add new item to the database.
The problem is that it doesn't recognize the path to the module Reglement.
I included it as follows:
require_once('modules/Reglement/Reglement.php');
but got the following error:
Error: Failed opening required 'modules/Reglement/Reglement.php'
Paths to my files:
js: custom/module_name/js/generate.js
php: custom/module_name/generateReg.php
Which file shall I include in order to recognize all the path?
Yes, I did that error :D, calling directly. I change the url in js file like this http://localhost.net/index.php?entryPoint=generateReg and it works now. Thank a lot.
But I've got an other error. When I call this url I send POST data. In my file I have the POST data, but the function json_decode($_POST['data']) return nothing.
print_r($_POST['data']) -> return a valid json
json_decode($_POST['data']) return nothing
Do you know if Sugar do something that change the behaviour of json_decode?
Related
I want to create a file and download it during a Laravel Action.
I use the following code:
public function handle(ActionFields $fields, Collection $models)
{
Storage::disk('local')->put('file.txt', 'example');
$url = Storage::disk('local')->url('file.txt');
return Action::download($url, 'file.txt');
}
This causes the following error :
Failed - no file
What am I doing wrong here?
Not sure where that error message comes from, but it may be the following problem. Calling return Action::download($url, 'file.txt') laravel nova will instruct the browser to download the file at the given url. As mentioned here this url will (depending on your config) probably be the relative url /storage/file.txt. So the browser will try to download http(s)://domain/storage/file.txt which might not be there. The docs mentioned above hold a solution for that.
If you wouldn't even want to create a file which would maybe need cleanup and protection if the data is sensitive, you could as well point the url to a route and do processing in a controller.
I want to load a php file dynamically. for example i have a website and i added new php file and it will load the new php file. is it possible without going through controller?
Try this, if you are not using cURL.
file_get_contents('http://YOUR_CODE_URL.com/send.php?'.$getdata, false, $context);
Furthermore, the method defaults to GET so you don't even need to set options, nor create a stream context. So, for this particular situation, you could simply call file_get_contents with the first parameter if you wish.
Im trying to connect to the FedEx PHP plugin, Ive successfully ran the plugin with my local Server. But when I try to run it on my CakePhp project I get the next error:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://my-subdomain.mydomain.com/controller/wsdl' : Entity 'raquo' not defined
Using the url I can actually enter the wdsl page and see the file in XML file. I got a function and view which return this. This is that functions code:
public function wsdl() {
$this->layout = false;
$this->RequestHandler->respondAs('xml');
}
I can enter the url and see the correct display of the XML. Then when I try using the wsdl on my function which is in the same class I get the error above. This is the code I use to call the SOAP class:
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "http://apibebe2go.bebe2go.com/home/wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1));
I get and internal error from the CakePhp debug and the error above. Any ideas what I could try to make this work? If you guys need any more code Ill be happy to help :D
Ok I solved the problem another way. Not sure why the /wdsl file was not working when called via function to view, BUT I added the .wdsl file to the WebRoot file path I had and called the url from there. Now it works like it should. If you need further explanation on how I achieved this, feel free to ask here :D
Cheers! :P
I am getting a strange 500 Internal Server Error with a new script I am trying to implement in the actual site. Here's a screen:
![500 Internal][1]
I can route to this files manually without problems and they are working too. But not in the script itself. The Paths are also correct.
Heres the link to the Site:
[>>> Link <<<][2] (just enter R10369 in the input field or a random number)
Everything else is working correctly except these 3 files:
reseller.php,
checkresellerid.php,
resellermail.php
I googled a bit and everywhere is the .htaccess mentioned. but I never modified it or overwrited it. What could be the Problem? Thanks for any Help and sorry for my bad Englisch.
(Let me know if you want to see the php files)
EDIT: I managed to include my new php files into wordpress but i still got the 500 Error
I checked out the website.
I think Wordpress doesn't let you call .php inside of it's system.
I mean you cannot call PHP files for ajax.
You need to use wordpress ajax. Here is a snippet how to use ajax:
Function.php in your theme file.
function myajax()
{
//do stuff
die();
}
add_action( 'wp_ajax_nopriv_product_s', 'myajax' );
add_action( 'wp_ajax_product_s', 'myajax' );
And in your javascript file using jQuery:
The url may change, maybe it's enough to have wp-admin/admin.ajax.php or something like this, i don't really remember right now.
$.post('/wp-admin/admin-ajax.php',{action:'myajax',yourdata:"mydata"}).done(function(data)
{
//do stuffs
});
Update:
So basically if you want to have ajax request inside wordpresss, you need to define these things and use it like this. the "action" parameter is the function name which you want to call. And you need to put the PHP code into your current theme's function.php.
I am attempting to build a PHPMailer based email system for a basic website.
This is the line of code that is giving me trouble:
$xajax->printJavascript('xajax/');
Now, this is the tutorial I am using.
Regarding the above line of code, the tutorial says this:
How to use the code inside a webpage?
Place the form (variable), the function (and the includes) before of all html code. Next we need to include some JavaScript file in the documents HTML header (place also php tags):
$xajax->printJavascript('xajax/');
When I run all of the code (including: PHPMailer script; Ajax script), I get this error, on the aforementioned line of code.
Fatal error: Call to a member function on a non-object
So, my question is, do I need to in someway customize this code or make it run to a filepath of some ajax core file or something?
I would be willing to be $xajax is not defined. Try adding this after including the libraries but before including the call to that method:
$xajax = new xajax();
There may be some additional setup required by xajax. A more complete code example could help troubleshoot.