javascript - Running a php script on a phonegap application -


i building app pulls data database. using ajax run php script located on external server , attempting return data json format. every time attempt run function calls script error stating url can not found. have added server domain whitelist in config file. i'm not sure else , appreciated.

here code.

index.html javascript run php script:

$(document).on("pagebeforeshow", "#articlelist", function(){         $.ajax({             url: "http://domain/app/script/getarticlelist.php",             type: "post",             datatype: "json",             data:{catid: catid},             success: function(data){                 alert("success");                 $("#article-list").empty();                 var li="";                 $.each(data, function(i,item){                     li += '<li><a href="" data-class="artselection" id="'+data[i].id+'">'+data[i].title+'</a></li>';                 });                  $("#article-list").append(li).promise();                 $("#article-list").listview('refresh');             },             error:function(x,e){                 if(x.status==0){                     alert('you offline!!\n please check network.');                 }else if(x.status==404){                     alert('requested url not found.');                 }else if(x.status==500){                     alert('internel server error.');                 }else if(e=='parsererror'){                     alert('error.\nparsing json request failed.');                 }else if(e=='timeout'){                     alert('request time out.');                 }else {                     alert('unknow error.\n'+x.responsetext);                 }             }         }); 

getarticlelist.php:

<?php     if (isset($_post['catid'])){         $server = "localhost";         $username = "username";         $password = "password";         $database = "database";          $con = mysqli_connect ($server, $username, $password, $database) or die ('could not connect: ' . mysqli_connect_error());         mysqli_set_charset($con,"utf8");          $list = array();         switch($catid){             case "catid=21":                 $qry = mysqli_query($con, "select title, id u9wkx_content ".$catid." , publish_down >= now() order `ordering` asc");                 break;             case "catid=90":                 $qry = mysqli_query($con, "select title, id u9wkx_content ".$catid." , publish_down >= now() order `title` asc");                 break;             case "catid=19":                 $qry = mysqli_query($con, "select title, id u9wkx_content ".$catid." , publish_down >= now() order `ordering` asc");                 break;             case "catid=107":                 $qry = mysqli_query($con, "select title, id u9wkx_content ".$catid." , publish_down >= now() order `ordering` asc");                 break;             case "catid=42":                 $qry = mysqli_query($con, "select title, id u9wkx_content ".$catid." , publish_down >= now() order `ordering` asc");                 break;             default:                 $qry = mysqli_query($con, "select title, id u9wkx_content ".$catid." , publish_down >= now()");         }          while($row = mysqli_fetch_assoc($qry)){         $list[] = $row;         }     }       header('content-type: application/json');     $list_data = json_encode($list);      echo $list_data; ?> 


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -