2012-05-07 3 views
1

나는 worpress 데이터에서 게시물 데이터를 선택하는 앱을 bulid하려고 시도했다. 내가 바닥에서 아약스를로드 할 때 말jquerymobile ajax issue

<?php /** 
     * @author yosef yawitz 
     * @copyright 2012 
     * @name index.php 
     **/ 
require_once 'inc/header.php'; 
/** 
* $query = 'inventory_sku'; 
* $a = wareHouseAllItems($query); 
*/ 
?> 
<script src="js/jqm.autoComplete-1.3.js"></script> 
<body> 
<div data-role="page" id="indexPage"> 

    <div data-role="header" data-position="fixed"> 
     <h1> בר דעת </h1> 
    </div> 
    <div data-role="content"> 
    <ul id="inventoryProducts"data-role="listview" data-theme="g"> 
     </ul> 
    </div> 
    <div data-role="footer"> 
     <h1>Comp</h1> 
    </div> 
</div> 
<script> 

     $(document).ready(function(){ 
     $('#inventoryProducts').load('inc/load_posts.php'); 
     }); 
</script> 
</body> 
</html> 

에 describeit 한 probalme : 그래서 그 모든 그냥이 내 코드 그것을 을 보여 JQuery와-moblie에서 <ul>의 간단한 <li> elmenets을 할 필요가 페이지의 <li> elemnet 정상적으로 표시하고 jquery CSS 스타일을 가지고 있지 않습니다.

답변

1

나는 동일한 문제가있었습니다.

$.ajax({ 
    type: 'POST', 
    url: inc/load_posts.php, 
    success:function(receivedData){ 
     // successful request; do something with the data 
     var myData = receivedData; 
     }, 
    error:function(){ 
     // failed request; give feedback to user 
     alert('Ajax call failed.'); 
    } 
}); 

을 그리고 당신은 Ajax 호출을 통해받은 게시물로 페이지를 업데이트하기 위해 자바 스크립트 코드를 사용의 라인을 따라 Ajax 호출, 뭔가.

$("#content").html(myData).page(); 
$("#content").page("destroy").page(); 

그것은 나를 위해 문제를 해결했습니다.

어쩌면 이것은뿐만 아니라 당신을 도울 수 있습니다 : http://blog.dkferguson.com/index.cfm/2011/3/15/jQuery-Mobile-styling-loaded-content

0
function loginfunction() 
{ 

    alert(1); 

    var uname=document.getElementById('uid').value; 
    var pword=document.getElementById('psw').value; 
    var query="UID="+uname+"&PWD="+pword; 

    alert(2); 

    $.ajax({ 
     url:"http://192.168.1.36/login.php", 
     type:"POST", 
     data:query, 
     timeout:10000, 
     success : function(data) 
     { 
      alert(3); 

      data=jQuery.parseJSON(data); 
      if(data==1){alert("success"); 
      window.location='Home.html';} 
      else if(data==0){alert("fail");} 
      }, 

    }); 


}