Jquery Mobile - Ajax调用从MySql数据库中的Json数据中获取数据返回错误。
这是我的代码
服务器代码
java.lang.IllegalStateException: Failed to transform class with name com.my.company.Util. Reason: cannot find org.apache.commons.httpclient.protocol.ProtocolSocketFactory
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:266)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:180)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
Caused by: javassist.CannotCompileException: cannot find org.apache.commons.httpclient.protocol.ProtocolSocketFactory
at javassist.expr.NewExpr.replace(NewExpr.java:215)
at org.powermock.core.transformers.impl.MainMockTransformer$PowerMockExpressionEditor.edit(MainMockTransformer.java:418)
at javassist.expr.ExprEditor.loopBody(ExprEditor.java:212)
at javassist.expr.ExprEditor.doit(ExprEditor.java:91)
at javassist.CtClassType.instrument(CtClassType.java:1431)
at org.powermock.core.transformers.impl.MainMockTransformer.transform(MainMockTransformer.java:74)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:251)
... 55 more
Caused by: javassist.NotFoundException: org.apache.commons.httpclient.protocol.ProtocolSocketFactory
at javassist.ClassPool.get(ClassPool.java:450)
at javassist.bytecode.Descriptor.toCtClass(Descriptor.java:592)
at javassist.bytecode.Descriptor.getParameterTypes(Descriptor.java:439)
at javassist.expr.NewExpr.replace(NewExpr.java:188)
... 61 more
我的ajax电话
<?php
try{
header('Content-type: application/json');
$server = "myurl";
$username = "username";
$password = "password";
$database = "mydb";
$con = mysqli_connect($server, $username, $password, $database) or die ("Could not connect: " . mysql_error());
/*mysql_select_db($database, $con);
$result = mysql_query($sql) or die ("Query error: " . mysql_error());
$records = array();
*/
$sql = "SELECT id, l_name AS name, l_lat AS value1, l_long AS value2 FROM landmarks ORDER BY l_name";
$result= mysqli_query($con, $sql);
$records = array();
while($row = mysqli_fetch_assoc($result)) {
$records[] = $row;
}
mysqli_close($con);
echo json_encode($records);
}
catch(Throwable $e) {
$trace = $e->getTrace();
echo $e->getMessage().' in '.$e->getFile().' on line '.$e->getLine().' called from '.$trace[0]['file'].' on line '.$trace[0]['line'];
}
?>
这里ajax正在返回错误函数。
控制台中没有记录任何内容。请帮助找出问题所在。