How to include php function name & class name JS File


#1

Hi,

I have created one admin menu(Config) for configuration, class name is “myconfiguration”. How to include this class name & function name in my js file and print the post values in my particular function name.
I have implemented one button in my Config page whenever click the button after only i called the js file and print the post values in my php funtion.

This URL is correct or not “url: ‘oxajax.php?cl=myconfiguration&fnc=configuration’,”
Example: http://localhost/oxid/admin/oxajax.php?cl=myconfiguration&fnc=configuration’;

Above url is correct or not.

jQuery.ajax({
url: ‘oxajax.php?cl=myconfiguration&fnc=configuration’,
type: ‘POST’,
dataType: ‘json’,
data: {
‘start’: jQuery(’#start_time’).val(),
‘end’: jQuery(’#end_time’).val(),
},
success: function(response) {
console.log(response);
},
error: function(response) {
console.log(response);
},
complete: function(response) {
}


#2

It should be like this: SHOPURL/index.php?cl=myconfiguration


#3

Hi rubbercut,

Thank you for your reply.

Your mentioned ulr is shop frontend, it’s working fine, but i need to use in admin side.


#4

SHOPURL/admin/index.php?..
i think, you should simply use index.php instead of oxajax.php


#5

Like VT has written, add “/admin” and you also can try it with relative paths. It’s not my way, but I would then add “/” in front to force loading the path.


#6

Hi Vanilla_thunder,

Thank you for your reply.

I already try this but it will be redirected to admin login page.


#7

for admin requests you need additional form data, like session id and token for authentication


#8

Please give me an some example.


#9

oxid shop is full of examples, its open soruce, simply look at any form in oxid admin


#10
var SHOPURL=document.location.host;    
 $.ajax({
                url: parent.location.protocol+"//"+SHOPURL+"/admin/index.php?cl=myconfiguration",

#11

This solutions also redirected to shop admin login page.


#12

Oh, it’s working in several modules :wink:
than maybe the folder /oxid/ is missing, Check it with console.log(SHOPURL);


#13

I send stoken value wrongly, so only i am getting redirect to admin login page. Now i send correct value it’s working fine.

Thank you very much.


#14

With pleasure :wink: