小编fil*_*ter的帖子

带有特殊字符的Json_decode

我通过jQuery Ajax将数据作为JSON发布到我的服务器上遇到了一个大问题.JSLint说数据没问题,请求的Content-Type设置为application/x-www-form-urlencoded; charset=UTF-8.服务器在PHP 5.2.11上运行,所以我无法使用json_last_error().

我尝试了url_decode,utf8_decode和html_entities_decode,但似乎没有任何效果.

var_dump(json_decode($jdata));返回null,但如果我做了var_dump($jdata)一切看起来没问题.$jdata是帖子数据:$jdata = $this->input->post('requestdata');.

这里从Firebug获取一些示例后期数据:

{
    "projectnumber": "345",
    "projecdescription": "345",
    "articles": [
        {
            "position": 1,
            "article_id": 677,
            "online_text": "3 Behälter; Band I-III nach indiv. Stückliste, Sprache: DE - Sprache: de"
        },
        {
            "position": 2,
            "article_id": 678,
            "online_text": "2 Behälter; Band I-III nach indiv. Stückliste, Sprache: ### - Sprache: en"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

编辑:

我现在试过这个:

$string = $this->input->post('requestdata');
var_dump($string);
$json = preg_replace('/,\s*([\]}])/m', '$1', utf8_encode($string));
$json = …
Run Code Online (Sandbox Code Playgroud)

php jquery json codeigniter

14
推荐指数
2
解决办法
2万
查看次数

在Google Maps Api v3中删除标记

我正在使用此功能向地图添加新标记(和折线):

 function addMarker(location) {

    path = poly.getPath();
    path.push(location);
    marker = new google.maps.Marker({
        position: location,
        icon:'location.png',
        title: poly.inKm() + ' km',
        map: map
    });
    markersArray.push(marker);
}
Run Code Online (Sandbox Code Playgroud)

如何删除最后一个标记(用于实现撤消)?

最好的祝福 ...

javascript google-maps-api-3 google-maps-markers

12
推荐指数
1
解决办法
2万
查看次数

如何定位使用传单的用户?

我正在尝试找到一个用户并使用传单将地图设置为此位置:

    <script>
    var map;

    function initMap(){
        map = new L.Map('map',{zoomControl : false});
        var osmUrl = 'http://{s}.tile.openstreetmap.org/mapnik_tiles/{z}/{x}/{y}.png',
            osmAttribution = 'Map data &copy; 2012 OpenStreetMap contributors',
            osm = new L.TileLayer(osmUrl, {maxZoom: 18, attribution: osmAttribution});
        map.setView(new L.LatLng(51.930156,7.189230), 7).addLayer(osm);
    }

    function locateUser(){
        map.locate({setView : true});
    }
</script>
Run Code Online (Sandbox Code Playgroud)

执行浏览器时请求权限,但是没有任何反应?我的代码出了什么问题?

javascript leaflet

9
推荐指数
2
解决办法
3万
查看次数

PHP变量到JQuery函数?

我在这个函数中需要一个相对路径:

    $(function() {
            $("#searchbox").autocomplete({
                    minLength : 2,
        source    : function (request, response){
                                $.ajax({
                                    url      : "http://linux/project/index.php/main/search/",
                                    dataType : "json",
                                    data     : { key : request.term},
                                    type     : "POST",
                                    success  : function(data){
                                    response($.map(data, function(item) {
                        return {
                            label: item.original_name,
                            value: item.original_name,
                                                            id   : item.project_id+"/"+item.folder_id+"/"+item.id
                        }
                    }))

                                           }
                            })
                            },
                    select : function(event, ui) {
                                document.location.href = "http://linux/project/index.php/projects/loaddocument/"+ui.item.id;
                             }

    });
});
Run Code Online (Sandbox Code Playgroud)

如何在上面的函数中使用PHP变量路径替换http:// linux/project

最好的祝福 ...

php jquery

4
推荐指数
1
解决办法
1238
查看次数

tcpdf Pagebreak的问题

我的网页破解有点问题.Multicell显示在第一页的页脚上,然后它中断:如何设置页面的下边距,以便在上面发生中断?这是示例PDF:示例,这里是源代码:

<?php require_once('../tcpdf/config/lang/eng.php'); 
  require_once('../tcpdf//tcpdf.php'); 

  class MYPDF extends TCPDF {
    public function Header() { 
      $auto_page_break = $this->AutoPageBreak;
      $this->SetAutoPageBreak(false,0); 
      $this->setJPEGQuality(100); $img_file = 'images/mandanten/ce_background.jpg';       
      $this->Image($img_file, $x=160, $y=72, $w=36, $h=200, $type='', $link='', $align='', $resize=true, $dpi=150, $palign='', $ismask=false, $imgmask=false, $border=0);        
      $this->SetAutoPageBreak($auto_page_break); } 
   }

 $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 
 $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('tmpAutor');  
 $pdf->SetTitle('tmpTitle'); $pdf->SetSubject('tmpSubject'); 
 $pdf->SetKeywords('tmp');   $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); 
 $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));                
 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); 
 $pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);                                   
 $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);  
 $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);             
 $pdf->SetAutoPageBreak(True, PDF_MARGIN_BOTTOM); 
 //set image scale factor 
 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
 //set some language-dependent strings 
 $pdf->setLanguageArray($l); $pdf->AddPage(); 
 $pdf->SetFont('freesans', …
Run Code Online (Sandbox Code Playgroud)

php tcpdf

3
推荐指数
1
解决办法
3万
查看次数

如何在android listview中使用simple_list_item_2?

我如何扩展我的示例以使用两行列表视图(例如从数据库中读出电子邮件)?

    ArrayList<String> db_results = new ArrayList<String>();
    Cursor c = db.rawQuery("SELECT lastname, firstname FROM contacts ORDER BY lastname",null);
    while(c.moveToNext()) {
        db_results.add(String.valueOf(c.getString(c.getColumnIndex("lastname"))) + ", " + String.valueOf(c.getString(c.getColumnIndex("firstname"))));
    }
    c.close();
    lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,db_results));
Run Code Online (Sandbox Code Playgroud)

谢谢 ...

android

1
推荐指数
1
解决办法
8481
查看次数