EasyUI Forum

General Category => General Discussion => Topic started by: AJLX on July 16, 2018, 03:14:38 PM



Title: AJAX Window
Post by: AJLX on July 16, 2018, 03:14:38 PM
Is there a way I can return an entire window using AJAX?

I currently have this AJAX call:

Code:

$.ajax({
url: 'ajax/update_project_item2.php',
type: 'post',
data: {'select':select,'items':jsonString},
  success: function(data, status) {
   $('#test').append(data);
  }

});

I have this PHP:

Code:
$type = $_POST['select']; // This is the select box option
$items = ($_POST['items']); // This is a Json string with the checkbox array in

 
 
 switch ($type)
 {
  case "mode":
 
  echo  '<div id="w" class="easyui-window" title="Basic Window" data-options="iconCls:\'icon-save\'" style="width:500px;height:200px;padding:10px;">
        The window content.
    </div>';
 
 
  break;
 
  case "position":
 
  break;
 
  case "colour":
 
  break;
 
  default:
 
  break;
 }
 

Ideally I could use each part of the case statement to return a different easyUI window. The reason for this is that I want to add a load of combo boxes that would be built dynamically based on the '$items' variable. This almost seems to work, but is missing something!

Thanks!


Title: Re: AJAX Window
Post by: jarry on July 17, 2018, 05:00:08 PM
No problem, you can get the html code from your server and parse it as an easyui component. Please refer to the code below:
Code:
$.ajax({
  url: 'test.php',
  method: 'post',
  type: 'html',
  success: function(data){
    var obj = $(data).appendTo('body');
    $.parser.parse(obj)
  }
})


Title: Re: AJAX Window
Post by: AJLX on July 18, 2018, 12:47:07 AM
Awesome- Thanks!