|
|
|
สอบถามเกี่ยวกับการใช้ Class ใน JSON หน่อยครับ (Yii Framework) |
|
|
|
|
|
|
|
รบกวนสอบถามเกี่ยวกับการใช้ class ใน JSON หน่อยครับ
ผมจะทำ dialog box ครับ เหมือนมันไม่วิ่งไปที่ class ให้อะครับ
ตรง tmp += '<td><a class="uimodal" href="index.php?height=350&width=700&title=11">Open</a></td>';
รบกวนช่วยดูให้หน่อยนะครับ ขอบคุณครับ
<script type="text/javascript">
function tb_parseQuery(query) {
var Params = {};
if (!query) { return Params; }// return empty object
var Pairs = query.split(/[;&]/);
for (var i = 0; i < Pairs.length; i++) {
var KeyVal = Pairs[i].split('=');
if (!KeyVal || KeyVal.length != 2) { continue; }
var key = unescape(KeyVal[0]);
var val = unescape(KeyVal[1]);
val = val.replace(/\+/g, ' ');
Params[key] = val;
}
return Params;
}
$(document).ready(function () {
$('a.uimodal').bind('click', function () {
var $this = $(this);
var url = $this.attr("href");
var queryString = url.replace(/^[^\?]+\??/, '');
var params = tb_parseQuery(queryString);
TB_WIDTH = (params['width'] * 1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
TB_HEIGHT = (params['height'] * 1) + 40 || $(document).height(); //defaults to 440 if no paramaters were added to URL
TB_Title = (params['title']);
$('<div>').dialog({
modal: true,
open: function () {
$(this).load(url);
},
height: TB_HEIGHT,
width: TB_WIDTH,
title: TB_Title
});
return false;
});
});
jQuery(function($) {
var result = $('#req_result');
//result.html('Loading, Please wait..');
$.ajax({
url: "<?php echo $this->createUrl('SearchAll')?>",
dataType: 'json',
cache: false,
type: 'post',
success: function(data) {
//var data = eval('('+f+')');
if(data!=""){
var tmp = '';
for(var i=0;i<data.length;++i){
tmp += '<tr class="gradeX">';
tmp += '<td><a class="uimodal" href="index.php?height=350&width=700&title=11">Open</a></td>';
tmp += '<td>'+data[i].node_name+'</td>';
tmp += '<td>'+data[i].start_date+'</td>';
tmp += '<td>'+data[i].end_date+'</td>';
tmp += '<td> </td>';
tmp += '<td>'+data[i].service+'</td>';
tmp += '<td>'+data[i].prov_subs+'</td>';
tmp += '<td>'+data[i].conn_subs+'</td>';
tmp += '<td>'+data[i].min_line+'</td>';
tmp += '</tr>';
}
//console.log(tmp);
}else{
tmp += '<tr class="gradeX"><td colspan="9" style="color: red;" >Not Found</td></tr>';
}
result.html(tmp);
}
});
});
</script>
Tag : PHP, JavaScript, Yii PHP Framework
|
|
|
|
|
|
Date :
2013-11-08 15:30:42 |
By :
ZeedzarD |
View :
703 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var obj = jQuery.parseJSON('<?=$str;?>');
$.each(obj, function(key, val) {
$("#div1").append('[' + key + '] ' + 'CustomerID=' + val["CustomerID"] +'<br />');
$("#div1").append('[' + key + '] ' + 'Name=' + val["Name"] +'<br />');
$("#div1").append('[' + key + '] ' + 'Email=' + val["Email"] +'<br />');
$("#div1").append('[' + key + '] ' + 'CountryCode=' + val["CountryCode"] +'<br />');
$("#div1").append('[' + key + '] ' + 'Budget=' + val["Budget"] +'<br />');
$("#div1").append('[' + key + '] ' + 'Used=' + val["Used"] +'<br />');
});
jQuery Ajax กับ JSON (Web Service) ทำความเข้าใจ การรับส่งข้อมูล JSON ผ่าน jQuery กับ Ajax
|
|
|
|
|
Date :
2013-11-09 08:55:50 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากครับ
เดี๋ยวลองทำดูครับ
|
|
|
|
|
Date :
2013-11-11 14:39:21 |
By :
ZeedzarD |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|