jQuery ajax返回负数而不是内容

时间:2016-08-05 09:53:27

标签: javascript php jquery html ajax

我在php中有这个:

return json_encode(array($raspuns, $table_licitatii, $option));

这在jQuery中:

request.done(function( msg ) {
  var result = $.parseJSON(msg);
  $("#done").html(result[0]);
  $("#table-licitatii").html(result[1]);
  $("#produs").html(result[2]);
});

使用#done和#produs我没有问题,没关系,但#table-licitatii而不是数据(表)出现数字(-1 -2)和每个请求(-2 -2,-3 -2) ,-4 -2,-5 -2,-6 -2)。 我该如何解决这个问题?

P.S。在#table-licitatii中,我必须像这样插入somenthing:

<table class="table table-striped">
            <thead>
                <tr>
                    <th>Product name</th>
                    <th>Product code</th>
                    <th><i class="fa fa-clock-o ceas"></i> <img src="/img/bid-icon.png" alt="Bid Icon"></th>
                </tr>
            </thead>
            <tbody>

                            <tr>
                    <td>TEST <small>( Amazon, Skype, PayPal)</small></td>
                    <td>LU5</td>
                    <td>9</td>
                </tr>

                            <tr>
                    <td>TESTT @@@ <small>( Amazon, Skype)</small></td>
                    <td>LU7</td>
                    <td>5</td>
                </tr>

            </tbody>
        </table>

1 个答案:

答案 0 :(得分:0)

尝试更改以下内容并控制结果:

在php中:

library(MASS)
library(LearnBayes)

means <- cbind(c(1,2,3),c(4,5,6))
chi <- 10

matgen<-function(means,chi,covariancematrix)
{
  cols <- ncol(means) # if means is a dataframe or matrix, this should work

  normals <- rnorm(n=20,mean=100,sd=10) # changed example for simplification
  # normals<-mvrnorm(n=20,mu=means,Sigma = covariancematrix) 
  # input to mu of mvrnorm should be a vector, see ?mvrnorm; but this means that ncol(means) is always 1 !?

  invgammas<-rigamma(n=20,a=chi/2,b=chi/2) # changed alpha= to a and beta= to b

  gen<-as.data.frame(matrix(data=NA,ncol=cols,nrow=20))

  i<-1
  while(i<=20)
  {
    gen[i,]<-t(means)+normals[i]*sqrt(invgammas[i]) # changed normals[i,] to normals [i], because it is a vector
    i<-i+1 # changed <= to <- 
  }
  return(gen)
}

matgen(means,chi,covariancematrix)

  return json_encode(array($raspuns, $table_licitatii, $option));