Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- baseurl="/forcart/";
- function loadProduct(id) {
- $.ajax({
- url: baseurl+'loadProduct.php?id='+id,
- success:function(json){
- obj = JSON.parse(json);
- if(obj.success == 1)
- {
- $('#name'+id).text(obj.proName);
- $('#select'+id).html(obj.proSet);
- }
- console.log(json);
- },
- error:function(error){console.log(error);}
- });
- }
- /***************************
- the php file
- ***************************/
- $proId = $_GET[id]
- $proSql = "select * from products where proCode='$proId'";
- $result = runQuery($proSql);
- $proName = '';
- $x=0;
- $select='';
- $jsonArray = array();
- if($result)
- {
- while($row = mysql_fetch_array($result))
- {
- $proName = $row['proName'];
- $select .="<option value='".$proName."'>".$proName."</option>" ;
- $x++;
- }
- $jsonArray = array(
- 'proName' => $proName,
- 'proSet' => $select,
- 'success' => 1
- );
- }
- else{
- $jsonArray = array(
- 'proName' => mysql_error(),
- 'proSet' => '',
- 'success' => 0
- );
- }
- return json_encode($jsonArray);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement