EasyUI Forum
May 03, 2024, 03:35:55 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: AJAX Window  (Read 5414 times)
AJLX
Newbie
*
Posts: 17


View Profile
« 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!
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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)
  }
})
Logged
AJLX
Newbie
*
Posts: 17


View Profile
« Reply #2 on: July 18, 2018, 12:47:07 AM »

Awesome- Thanks!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!