Jquery ajax json解析错误(Jquery ajax json Parse error)
当我传递ajax值时,它说json parseererror,尝试了jsonp但没有工作。 这是我的代码:
HTML:
<form class="ajaxform" method="post"> <div class="form-group form-inline"> <label for="searchtxt">Search Here: </label> <input type="text" name="ajaxinput" class="form-control ajaxinput"> </div> <div class="form-group"> <a href="" class="ajaxsubmit btn btn-primary">Get Data</a> </div> </form>
PHP:
$return_array = array(); $query = "select * from tbl_admin where uName like '%".$ajaxinput."%' or uEmail like '%".$ajaxinput."%'"; $abc = $db->pdoQuery($query)->results(); foreach ($abc as $key => $value) { # code... $return_array['admin_name'] = $value['uName']; $return_array['admin_email'] = $value['uEmail']; $return_array['admin_ip'] = $value['ipAddress']; echo json_encode($return_array); } exit();
JQUERY:
$('.ajaxsubmit').on('click', function(e){ e.preventDefault(); var urlPath = siteName+'modules-nct/ajax-nct/ajax.ajax-nct.php'; var mydata = jQuery(".ajaxform").serialize(); $.ajax({ url: urlPath, data : mydata, dataType: 'json', success: function(response){ console.log(response); alert(response); }, error: function(xhr, status){ console.log(status); } }); });
我想要json中的数据,因为我必须将它附加到表中。 在数据类型中:html数据来了但不是很有用,因为它包含多个记录。
when i pass ajax values it says json parseererror, tried jsonp but not working. Here's my code:
HTML:
<form class="ajaxform" method="post"> <div class="form-group form-inline"> <label for="searchtxt">Search Here: </label> <input type="text" name="ajaxinput" class="form-control ajaxinput"> </div> <div class="form-group"> <a href="" class="ajaxsubmit btn btn-primary">Get Data</a> </div> </form>
PHP:
$return_array = array(); $query = "select * from tbl_admin where uName like '%".$ajaxinput."%' or uEmail like '%".$ajaxinput."%'"; $abc = $db->pdoQuery($query)->results(); foreach ($abc as $key => $value) { # code... $return_array['admin_name'] = $value['uName']; $return_array['admin_email'] = $value['uEmail']; $return_array['admin_ip'] = $value['ipAddress']; echo json_encode($return_array); } exit();
JQUERY:
$('.ajaxsubmit').on('click', function(e){ e.preventDefault(); var urlPath = siteName+'modules-nct/ajax-nct/ajax.ajax-nct.php'; var mydata = jQuery(".ajaxform").serialize(); $.ajax({ url: urlPath, data : mydata, dataType: 'json', success: function(response){ console.log(response); alert(response); }, error: function(xhr, status){ console.log(status); } }); });
i want data in json as i have to append it in a table. In datatype: html data comes but not that useful as it contains multiple records.
原文:https://stackoverflow.com/questions/48496519
更新时间:2023-07-19 13:07
最满意答案
在终端中转到您的项目目录 ,并启动您的反应原生服务器 ,它将为您工作。
Go to your project directory in terminal and start your react-native server it will work for you.
相关问答
更多-
您可以尝试将suspend=False传递给pydevd.settrace() ,以防PyCharm在应用此设置时遇到问题。 You could try passing suspend=False to pydevd.settrace() in case PyCharm has some problem with applying this setting itself.
-
我们花了一段时间才找到这个解决方案 - 我分享它,希望它可以节省其他麻烦 它似乎与Windows XP有关或仅限于它,它似乎也与您的域上的设置有关 - 尽管我们没有发现。 解决方案是从Microsoft安装此修补程序 。 您将需要安装Windows XP Service Pack 3 这对我们在同一个域内的四台机器上工作。 It took us a while to find this solution - I share it in the hope it saves others the same ha ...
-
ssh -L 5005:localhost:5005 haseeb@myserver.com 将localhost:5005映射到myserver.com上的端口5005 (也在myserver.com localhost接口上)。 这样在IntelliJ IDEA调试器中,您将连接到localhost (在Host字段中指定)端口5005 ,连接将被转发到调试器侦听localhost:5005的远程服务器。 有关SSH隧道如何工作的详细信息,请参见此处 ssh -L 5005:localhost:5005 ...
-
无法连接到远程调试器(Unable to connect to remote debugger)[2022-05-16]
在终端中转到您的项目目录 ,并启动您的反应原生服务器 ,它将为您工作。 Go to your project directory in terminal and start your react-native server it will work for you. -
我相信这是存储在,并可以从控制面板\用户帐户\凭证管理器进行管理。 I believe that is stored in and can be managed from Control Panel\User Accounts\Credential Manager.
-
ANTLR“无法启动调试器。(ANTLR “Cannot launch the debugger. Time-out waiting to connect to the remote parser.”)[2023-09-29]
我发现Windows防火墙规则可能会干扰调试器,因此请确保您没有将其设置为阻止Java VM。 此外,请稍等一会,然后选择“调试远程”选项,调试器通常需要一些时间并且主进程超时,但调试器仍然出现。 I've found that the Windows firewall rules can really interfere with the debugger, so make sure you haven't set it to block the Java VM. Also, try waiting a ... -
Terado怎么样? 或任何其他IPoverIP? 我认为在某种类型的家用路由器后面会更容易,每次连接时,你只需配置(它们通常称之为“DMZ”端口)来动态重定向。 最糟糕的情况,尝试这样的事情, 甚至 。 在其他溢出论坛上也许更好? It appears I have finally found a solution. A post here pointed me in the right direction, following these instructions. I had tried someth ...
-
有没有办法检测附加的调试器是否是远程调试器?(Is there a way to detect whether the attached debugger is remote-debugger?)[2021-09-04]
您可以使用kernel32.dll的本机CheckRemoteDebuggerPresent 来自MSDN : CheckRemoteDebuggerPresent中的“远程”并不意味着调试器必然驻留在另一台计算机上; 相反,它表示调试器驻留在一个单独的并行 进程中。 您可以按如下方式使用它: [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] static extern bool CheckRemoteDebugge ... -
检查此处列出的所有步骤: https : //msdn.microsoft.com/en-us/library/dwesw3ee.aspx?f = 255&MSPPError = -2147217396 如果您使用的是hosts文件,请确保您有相关网站的条目。 当我遇到这条消息时,这对我来说是个问题。 Check all the steps outlined here: https://msdn.microsoft.com/en-us/library/dwesw3ee.aspx?f=255&MSPPErro ...
-
基于对32位和64位Windows 8的测试。 1)安装32位版本的Android SDK(即使在64位窗口上) 2)确保安装了32位Java运行时 3)将安装的Eclipse exe作为Android下载的一部分设置为在Windows XP SP3兼容模式下运行 4)配置Eclipse以使用ADBHost Based on testing on both 32-bit and 64-bit Windows 8. 1) Install the 32-bit version of the Android SD ...