Issue #1212Opened June 18, 2018by sfrancy0 reactions

Ajax Call, Button in a Panel

Question

I'm tryng to do an ajax call for a button inside the panel this is my code:

// Add devices buttons
  const panelDevices = pn.addPanel({id: 'loggedas'});
  panelDevices.get('buttons').add([
 {
   id: 'save',
className: 'fa fa-save icon-undo',
text:'A',
run: function(editor,sender)
{
if(sender) sender.set('active',false);

},
command:  function(editor,sender)
{
if(sender) sender.set('active',false);
if (confirm("Are you sure??") == true) {
          var htmldata = editor.getHtml();
          var cssdata = editor.getCss();
		  var pagetosave = "<head> <style>" + cssdata + "</style> </head> <body>" + htmldata + "</body>";
		      alert(pagetosave);
			 $.ajax({
     url: "../php.php",
     type: "POST",
	 async: false ,
     contentType: "text/html",
     data: data,
     success: function(res){
       alert(res);
     },
     error: function(res){
       alert(res);
     }
  });

     } else {
         x = "You pressed Cancel!";
     }},
attributes: { title:'Save'}
}

]);

of course i hosted it on a web, but i dont recive response(error or succes) and i tryed an hello world inside the php, but i think the request never started.

Answers (3)

sfrancyJune 20, 20180 reactions

my bad, i used FDE with the console, i just forgot to include jquery.

lock[bot]September 17, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.