Cannot read property 'add' of undefined

vue打包时报这个错误,但是我代码中没有写add, 调试只知道问题点应该在post请求下面用到了cooike,但是cookie单独写在外面就不会报错 . 错误: Module build failed: TypeError: E:/dev/src/pages/Login/Login.vue: Cannot read property 'add' of undefined 图片说明



Csdn user default icon
Uncaught TypeError: Cannot read property 'options' of undefined

使用easyui 循环添加tabs for(var i=0;i<9;i++){ $("#tt").tabs('add',{ title:'aaa', content:"bbbb", closable:true, }); } 只进行了一次添加,然后终止。经浏览器调试 在jquery.easyui.min.js 3648行中报了一个错 function _2b7(_2b8,_2b9){ var opts=$.data(_2b8,"tabs").options; Uncaught TypeError: Cannot read property 'options' of undefined var tabs=$.data(_2b8,"tabs").tabs; if(_2b9.selected==undefined){ _2b9.selected=true; } Uncaught TypeError: Cannot read property 'options' of undefined

Vue控制台报错Uncaught (in promise) TypeError: Cannot read property 'instructor' of undefined at eval

Vue控制台报错Uncaught (in promise) TypeError: Cannot read property 'instructor' of undefined at eval 代码如下 ``` ajax.POST('login', loginData) // axios里data与params区别 .then(function (res) { that.loginStatus.loading = false if (['instructor'] === 'instructor') { roleInfo.role = 'instructor' } ``` php代码 ``` public function login () { $dataArr = request()->param(); $role = $dataArr['role']; $instructor = ''; if ($role === 'admin') { $selectSql = "select admin_username as fullname,password from beta_administrator where admin_username = ?"; } elseif ($role === 'student') { $selectSql = "select stu_name as fullname,password from beta_student where stu_number = ?"; }else { $selectCounselorSql = "select * from beta_instructor where ins_number = ?"; $selectCounselorRes = Db::query($selectCounselorSql, [$dataArr['username']]);//获取结果集 $vs = check_before_add_data($selectCounselorRes);//判断结果集是否为空 if ( $vs === 1 ){ $instructor = 'instructor'; } $selectSql = "select tea_name as fullname,password from beta_teacher where tea_number = ?"; } $selectRes = Db::query($selectSql, [$dataArr['username']]); $v = check_before_add_data($selectRes); if ($v === 1) { if ($selectRes[0]['password'] === $dataArr['password']) { return_json(['fullName' => $selectRes[0]['fullname'],'instructor' => $instructor], 'ok', 200); } else { return_json('','账户或密码错误',400); } } elseif ($v === 0) { return_json('','用户名不存在',400); } else { return_json('','登录失败,未知错误',400); } } } ``` 请求大神指正

js报错Uncaught TypeError: Cannot read property '1' of null

![图片说明]( ![图片说明]( 字符串可以正常输出到控制台,并且相同的字符串在控制台运行这段代码没有问题,找了很多解决方法,加入非空判断,把代码放到</body>后等都无用

ionic报错 'hasOwnProperty' of undefined

执行到ionic platform add android这一步报错: TypeError: Cannot read property 'hasOwnProperty' of undefined ![图片说明](

学习ztree遇到TypeError: tId is undefined,跪求大神

``` <!DOCTYPE html> <HTML> <HEAD> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href=""stylesheets/css/zTreeStyle/zTreeStyle.css")" type="text/css"> <script src=""javascripts/jquery-1.9.0.min.js")" type="text/javascript"></script> <script type="text/javascript" src=""javascripts/js/jquery.ztree.core-3.5.js")"></script> <SCRIPT type="text/javascript"> var zNodes; var setting = { data: { simpleData: { enable: true, idKey:"id", pIdKey:"pId", rootPId:0 } }, showLine : true, //是否显示节点间的连线 checkable : true //每个节点上是否显示 CheckBox }; $(document).ready(function(){ $.ajax({ async : false, cache:false, type: 'GET', dataType : "json", url: "/Application/getData",//请求的action路径 error: function () {//请求失败处理函数 alert('请求失败'); }, success:function(data){ //请求成功后处理函数。 alert(data); zNodes = data; //把后台封装好的简单Json格式赋给treeNodes } }); $.fn.zTree.init($("#treeDemo"), setting, eval(zNodes)); }); </SCRIPT> </HEAD> <BODY> <div class="content_wrap"> <div class="zTreeDemoBackground left"> <ul id="treeDemo" class="ztree"></ul> </div> </div> </BODY> </HTML> ``` 下面是Java部分代码: ``` public static Result getData() { String s1 = "{id:1, pId:0, name:\"test1\" , open:true}"; String s2 = "{id:2, pId:1, name:\"test2\" , open:true}"; String s3 = "{id:3, pId:1, name:\"test3\" , open:true}"; String s4 = "{id:4, pId:2, name:\"test4\" , open:true}"; List<String> lstTree = new ArrayList<String>(); lstTree.add(s1); lstTree.add(s2); lstTree.add(s3); lstTree.add(s4); return ok(Json.toJson(lstTree)); } ``` 下面是JSON返回的数据: ![ajax返回的数据]( 所用框架是play framework,求大神解惑,为什么会出现TypeError: tId is undefined的错误呢? # ![出现的错误](

是否可以从JS显式调用导出的Go WebAssembly函数?

<div class="post-text" itemprop="text"> <p><strong>Is it possible to call a Go WebAssembly function, other than <code>main</code>, in Javascript?</strong></p> <p>Let me first show what I did. My Go functions are defined as follows:</p> <pre class="lang-golang prettyprint-override"><code>package main import "fmt" func main() { fmt.Println("it works!") } func add(a, b int) int { return a + b } </code></pre> <p>I can only invoke the <code>main</code> function:</p> <pre class="lang-js prettyprint-override"><code>const go = new Go(); const data = await fetch("http://localhost:3333/main.wasm"); const result = await WebAssembly.instantiateStreaming(data, go.importObject);; </code></pre> <p>which returns <code>it works!</code> as expected.</p> <p>However, whenever I try to invoke the <code>add</code> function, I receive <code>TypeError: Cannot read property 'add' of undefined at Welcome.getWasm</code>, because both <code>result.exports</code>, <code>result.instance.exports</code> do not contain my function. I also tried capitalizing the Go function, but at no avail.</p> <p>Thus, I started wondering what could be a problem – <strong>is it even possible to call a random Go function from Javascript?</strong> Or can I only call the default <code>main()</code> function?</p> </div>

Quasar Vue Laravel-Echo实施

<div class="post-text" itemprop="text"> <p>Im using quasar framework and trying to add laravel-echo with Socket server is up and running and broadcasting event with no issues. </p> <p>But for some reason my client side does not want to connect it keeps giving me error that cannot read property 'channel' of undefined.</p> <p>My Setup</p> <p><strong>package.json</strong></p> <pre><code>"laravel-echo": "^1.5.4", "quasar": "^1.0.5", "": "^2.2.0", </code></pre> <p><strong>boot/laravel-echo.js</strong></p> <pre><code>import Echo from 'laravel-echo' = require('') const echo = new Echo({ broadcaster: 'socket-io', host: window.location.hostname + ':6001' }) export default ({ Vue }) =&gt; { Vue.prototype.$echo = echo } </code></pre> <p><strong>quasar.conf.js</strong></p> <pre><code>boot: [ 'axios', 'laravel-echo' ], </code></pre> <p><strong>index.vue</strong></p> <pre><code>created () { this.listen() }, methods: { listen() { this.$'test').listen('event', payload =&gt; { console.log('THIS IS THE PAYLOAD: ' + payload) }) } } </code></pre> <p><strong>Browser</strong></p> <pre class="lang-sh prettyprint-override"><code>[Vue warn]: Error in created hook: "TypeError: Cannot read property 'channel' of undefined" found in ---&gt; &lt;AllEvents&gt; &lt;QPage&gt; &lt;DashboardIndex&gt; at src/pages/dashboard/Index.vue &lt;QPageContainer&gt; </code></pre> <p><strong></strong></p> <pre class="lang-sh prettyprint-override"><code>L A R A V E L E C H O S E R V E R version 1.5.6 ⚠ Starting server in DEV mode... ✔ Running at localhost on port 6001 ✔ Channels are ready. ✔ Listening for http events... ✔ Listening for redis events... Server ready! Channel: test Event: event </code></pre> <p>I have even change the code to the same as in the laravel documentation (<a href="" rel="nofollow noreferrer"></a>) with window.Echo</p> <pre><code>import Echo from 'laravel-echo' = require('') window.Echo = new Echo({ broadcaster: 'socket-io', host: window.location.hostname + ':6001' }) export default async ({ Vue }) =&gt; { } </code></pre> <p>and trying to connect to channel</p> <pre><code>'test').listen('event', payload =&gt; { console.log('Here') console.log(payload) }) </code></pre> <p>but still getting the same error on the browser, not sure what im missing here, any help would be greatly appreciated.</p> </div>

Magento 2.1中的Javascript冲突

<div class="post-text" itemprop="text"> <p>I am using an External javascript in the magento2 Block. That external javascript is calling its own jquery library. And this is conflicting with the Magento jquery.</p> <p>Now, am getting this errors:</p> <blockquote> <ol> <li><p>Uncaught TypeError: $.widget is not a function</p></li> <li><p>Uncaught TypeError: Cannot read property 'timepicker' of undefined</p></li> <li><p>Uncaught TypeError: Cannot read property 'initObserversForPopup' of undefined</p></li> </ol> </blockquote> <p>Please help me Resolving this issue.</p> <p>I also try to add this external js at the Head section and at the end of body tag.</p> <p>Regards,</p> </div>

执行npm install -g @vue.cli报错

由于之前没有接触过前端,所以这次做一个前后端分离的项目要用的Vue框架,这里我安装vue cli3 的时候报错,试了好多方法都没解决,请问一下我这个问题应该怎么去解决,请大家帮忙看一下,谢谢![图片说明](

Javascript - 未捕获的TypeError:无法读取未定义的属性“值”

<div class="post-text" itemprop="text"> <p>I am currently converting my friends website, as it's not "mobile friendly" by changing his current frontend into a bootstrap front end.</p> <p>I've been working on a test site which is just a sub-domain on the same server.</p> <p>This is the old website: <a href="" rel="nofollow"></a> </p> <p>This is the new website: <a href="" rel="nofollow"></a> </p> <p>But I've encountered a problem with the shopping cart page.</p> <p>The shopping cart no longer recalculates its total when I press the recalculate button. It works fine on the old website. I dont know what I've changed to break it?</p> <p>I've debugged the JavaScript using Chrome Dev Tools (F12) and line no 150 of order.php has this error:</p> <pre><code>Uncaught TypeError: Cannot read property 'value' of undefined </code></pre> <p>And this is the line of offending code:</p> <pre><code>if (document.forms[1].elements["qty" + count].value == "" || document.forms[1].elements["qty" + count].value == 0) { document.forms[1].elements["qty" + count].value = 0; showInCart = false; } </code></pre> <p>I don't understand why I am getting this error? Googling around gives vague answers. Which is why I am here on StackOverflow.</p> <p>BTW if you want to recreate my problem you'll need to:</p> <ol> <li><p>go to the homepage</p></li> <li><p>choose a product category from the grid of pictures e.g. "get costume ideas..."</p></li> <li><p>add an item to the basket.</p></li> <li><p>once the page posts to Order.php Change its Quantity.</p></li> <li><p>click the recalculate button.</p></li> </ol> <p>Why is the Javascript no longer picking up the values from the quantity fields???</p> <p>Any help is greatly appreciated.</p> <p>Here is the function in its entirety:</p> <pre><code>&lt;script type="text/javascript"&gt; function recalculateTotal(){ var lineTotal = 0; var subTotal = 0; var total = 0; var hiddenStuff = ""; var count; var i; var orderURL="register.php?orderDetails="; items = new Array(&lt;?=$itemList?&gt;); for (i in items){ var cNum = 0; var pNum = 0; var qNum = 0; count = items[i]; cNum = (count * 4) + 1; var showInCart = true; // the next line is broken! if (document.forms[1].elements["qty" + count].value == "" || document.forms[1].elements["qty" + count].value == 0){ document.forms[1].elements["qty" + count].value = 0; showInCart = false; } lineTotal = document.forms[1].elements["qty" + count].value * document.forms[1].elements["price" + count].value; document.getElementById("lTotal" + count).innerHTML = formatCurrency(lineTotal); subTotal += lineTotal; if (hiddenStuff == ""){ hiddenStuff = hiddenStuff + showInCart + ":" + document.forms[1].elements["productId" + count].value + ':' + document.forms[1].elements["qty" + count].value; }else{ hiddenStuff = hiddenStuff + ":" + showInCart + ":" + document.forms[1].elements["productId" + count].value + ':' + document.forms[1].elements["qty" + count].value; } } document.getElementById("subTotal").innerHTML = formatCurrency(subTotal); for (var j in delivery_prices){ if (subTotal &gt;= delivery_prices[j].total_amount_start &amp;&amp; subTotal &lt;= delivery_prices[j].total_amount_end){ document.getElementById('delivery').innerHTML = delivery_prices[j].delivery_price; total = subTotal + delivery_prices[j].delivery_price; } } document.getElementById("total").innerHTML = formatCurrency(total); document.forms[1].elements["orderDetails"].value = hiddenStuff; orderURL = orderURL + hiddenStuff; var myrequest = $.ajax({ url: orderURL, type: "get", }); myrequest.done(function (response){ updateBasket(); }); } &lt;/script&gt; </code></pre> <p>Thanks very much.</p> </div>


``` ``` 代码如下: var tab = $("<div id='tab_row_" + r + "_column_" + c + "' class='easyui-tabs' style='width:500px;height:250px;'>"); var content = "<table id='table_datagrid_'" + +"></table>"; tab.tabs('add', { title: view.title, content : content, closable: true }); 执行到add的时候,就报出了如下错误: jquery.easyui.js:5210 Uncaught TypeError: Cannot read property 'options' of undefined at _34c (jquery.easyui.js:5210) at HTMLDivElement.<anonymous> (jquery.easyui.js:5469) at Function.each (jquery-1.9.1.min.js:132) at init.each (jquery-1.9.1.min.js:41) at Object.add (jquery.easyui.js:5468) at init.$.fn.tabs (jquery.easyui.js:5431) at DataBrowser.showReport (db.databrowser.js:180) at Object.$.parser.onComplete (db.databrowser.js:91) at Object.parse (jquery.easyui.js:46) at jquery.easyui.js:3276 是不是add方法只能用于给静态div添加tab呢?


<div class="post-text" itemprop="text"> <p>I am trying to add AutoComplete in my html</p> <p><a href="" rel="nofollow">JQUERY AUTOCOMPLETE FILE LINK</a> Here is how i have added it </p> <pre><code>&lt;script src="&lt;?php echo $site_root?&gt;js/autocomplete/jquery.ui.autocomplete.autoSelect.js"&gt;&lt;/script&gt; </code></pre> <p>Trying to access using</p> <pre><code>$("#username").autocomplete({ source: &lt;?php echo $username; ?&gt;, select: function(event, ui) { var username = ui.item.label; window.location = 'submissionForm.php?username=' + username; } }); </code></pre> <p>I am getting This error Cannot read property 'autocomplete' of undefined</p> <p>What is wrong?</p> </div>


<div class="post-text" itemprop="text"> <p>Creating my first Wordpress Plugin and having an issue with JavaScript loading.</p> <p>I'm defining a Class which runs several functions that include JavaScript via <code>wp_enqueue_script</code>. </p> <p><strong>Here is a sample <code>JS</code> file Demonstrating Problem:</strong></p> <pre><code>//The alert will fire alert('javascript is firing'); // This will return an error saying //Cannot read property 'setAttribute' of undefined document.getElementsByTagName("body")[0].setAttribute("ng-app", "app"); </code></pre> <p><strong><code>plugin.php:</code></strong></p> <pre><code>&lt;?php /* Plugin Name: Wordpress Plugin Plugin URI: Description: A Wordpress Plugin Author: Me Version: 1.0 Author URI: */ define('Wordpress Plugin', '1'); class wordpressPlugin { function __init(){ add_action( 'wp_enqueue_scripts', array( $this, 'angularScripts')); } function angularScripts(){ wp_enqueue_script('app', plugin_dir_url( __FILE__).'js/app.js',array('jquery'), null, false); } //Create instance of class $wpNG = new wordpressPlugin(); // Activate Plugin add_action( 'init', array( $wpNG, '__init' ), 1000 ); ?&gt; </code></pre> <p><strong><code>app.js</code></strong></p> <pre><code>alert('hello'); document.getElementsByTagName("body")[0].setAttribute("ng-app", "app"); </code></pre> <p>The alert will fire but the <code>document.getElements</code> will not run and return an error of undefined. But, if I wrap this within a <code>window.onload</code> function the <code>document.getElements</code> will run fine. Doing a <code>window.onload</code> is not the desirable. </p> <p>How does the <code>JavaScript</code> need to be set up to run without needing <code>window.onload</code>?</p> </div>


<div class="post-text" itemprop="text"> <p>I've managed to make Filepond upload files, put them in the right folder and add the necessary details to a mysql database. However, since the original images are very high resolution, I need to make thumbnails. Smaller versions of the images that should go in a subfolder called "thumbnails". </p> <p>I am using the PHP boiler plate, and some of the documentation don't cover the methods used there. For instance, I tried, just for testing, to do this: </p> <pre><code> FilePond.setOptions({ maxFileSize: '25MB', instantUpload: true, server: 'api/', imageTransformVariants: { 'thumb_medium_': transforms =&gt; { transforms.resize.size.width = 384; return transforms; }, 'thumb_small_': transforms =&gt; { transforms.resize.size.width = 128; return transforms; } } }); let pond = FilePond.create(document.querySelector('input[type="file"]')); </code></pre> <p>Which gives me this error: </p> <pre><code>index.php?id=1383:67 Uncaught (in promise) TypeError: Cannot read property 'size' of undefined at thumb_medium_ (index.php?id=1383:67) at filepond-plugin-image-transform.js:898 at filepond-plugin-image-transform.js:987 at new Promise (&lt;anonymous&gt;) at filepond-plugin-image-transform.js:986 at filepond-plugin-image-transform.js:1066 at (&lt;anonymous&gt;) at filepond-plugin-image-transform.js:1065 at new Promise (&lt;anonymous&gt;) at filepond-plugin-image-transform.js:941 </code></pre> <p>Obviously I could make a second Filepond-upload for the thumbnails but I suspect there should be a way to do this automatically. How do I make variants work and also, how to make them in a different folder and the same filename, rather than giving them a prefix?</p> </div>

这个错误在 PHP 中是什么意思?

<div class="post-text" itemprop="text"> <h3>What is this?</h3> <p>This is a number of answers about warnings, errors and notices you might encounter while programming PHP and have no clue how to fix. This is also a Community Wiki, so everyone is invited to participate in adding to and maintaining this list. </p> <h3>Why is this?</h3> <p>Questions like <a href="">"Headers already sent"</a> or <a href="">"Calling a member of a non-object"</a> pop up frequently on Stack Overflow. The root cause of those questions is always the same. So the answers to those questions typically repeat them and then show the OP which line to change in his/her particular case. These answers do not add any value to the site because they only apply to the OP's particular code. Other users having the same error can not easily read the solution out of it because they are too localized. That is sad, because once you understood the root cause, fixing the error is trivial. Hence, this list tries to explain the solution in a general way to apply.</p> <h3>What should I do here?</h3> <p>If your question has been marked as a duplicate of this, please find your error message below and apply the fix to your code. The answers usually contain further links to investigate in case it shouldn't be clear from the general answer alone.</p> <p>If you want to contribute, please add your "favorite" error message, warning or notice, one per answer, a short description what it means (even if it is only highlighting terms to their manual page), a possible solution or debugging approach and a listing of existing Q&amp;A that are of value. Also, feel free to improve any existing answers.</p> <h2>The List</h2> <ul> <li><a href="">Nothing is seen. The page is empty and white.</a> (also known as <em>White Page/Screen Of Death</em>)</li> <li><a href="">Code doesn't run/what looks like parts of my PHP code are output</a></li> <li><a href="">Warning: Cannot modify header information - headers already sent</a></li> <li><a href="">Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given</a> a.k.a.<br> <a href="">Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource</a> a.k.a.<br> <a href="">Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given</a> (or similar variations)</li> <li><a href="">Warning: <em>[function]</em> expects parameter 1 to be resource, boolean given</a></li> <li><a href="">Warning: <em>[function]</em>: failed to open stream: <em>[reason]</em></a></li> <li><a href="">Warning: open_basedir restriction in effect</a></li> <li><a href="">Warning: Division by zero</a></li> <li><a href="">Warning: Illegal string offset 'XXX'</a></li> <li><a href="">Parse error: syntax error, unexpected '['</a></li> <li><a href="">Parse error: syntax error, unexpected T_XXX</a></li> <li><a href="">Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE</a></li> <li><a href="">Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM</a></li> <li><a href="">Parse error: syntax error, unexpected 'require_once' (T_REQUIRE_ONCE), expecting function (T_FUNCTION)</a></li> <li><a href="">Parse error: syntax error, unexpected T_VARIABLE</a></li> <li><a href="">Fatal error: Allowed memory size of XXX bytes exhausted (tried to allocate XXX bytes)</a></li> <li><a href="">Fatal error: Call to a member function ... on a non-object</a></li> <li><a href="">Fatal Error: Call to Undefined function XXX</a></li> <li><a href="">Fatal Error: Cannot redeclare XXX</a></li> <li><a href="">Fatal error: Can't use function return value in write context</a></li> <li><a href="">Fatal error: Declaration of AAA::BBB() must be compatible with that of CCC::BBB()</a> '</li> <li><a href="">Fatal error: Using $this when not in object context</a></li> <li><a href="">Notice: Array to string conversion</a></li> <li><a href="">Notice: Trying to get property of non-object error</a></li> <li><a href="">Notice: Undefined variable</a></li> <li><a href="">Notice: Undefined Index</a></li> <li><a href="">Notice: Undefined offset XXX</a> [Reference]</li> <li><a href="">Notice: Uninitialized string offset: XXX</a></li> <li><a href="">Notice: Use of undefined constant XXX - assumed 'XXX'</a></li> <li><a href="">MySQL: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ... at line ...</a></li> <li><a href="">Strict Standards: Non-static method <em>[&lt;class&gt;::&lt;method&gt;]</em> should not be called statically</a></li> <li><a href="">Warning: function expects parameter X to be boolean/string/integer</a></li> </ul> <p>Also see </p> <ul> <li><a href="">Reference - What does this symbol mean in PHP?</a></li> </ul> </div> <p>转载于:</p>


<div class="post-text" itemprop="text"> <p>Good day,</p> <p>I have final changes of feature on draw.on("drawend") also on drawend i try to export feature</p> <pre><code>var feature = event.feature; var cache = []; jsonFeature = JSON.stringify( feature, function(key, value) { if (typeof value === "object" &amp;&amp; value !== null) { if (cache.indexOf(value) !== -1) { return; } cache.push(value); } return value; } ); cache = null; </code></pre> <p>and trying to pass it to RPC layer to save to database, but after converting it back to Object i get errors</p> <pre><code>var clone = JSON.parse(jsonFeature); vectorSource.addFeature(clone); </code></pre> <p><strong>Uncaught TypeError: feature.getId is not a function</strong></p> <p>How can i correctly pass feature or split feature into array to save it into DB via PHP and then return it back from DB to ol.source.Vector with all styles, images, canvas, coordinates, etc.?</p> <p>Every feature contains it's own styling, some of them, like marker, have image and some, like arrowLine, have canvas of arrows head at LineString event.feature.getGeometry().getLastCoordinate();</p> <p>** Edit **</p> <p>Found solution by using ol.format.KML</p> <pre><code>var kml = new ol.format.KML(); var jsonFeature = kml.writeFeatures([feature]); </code></pre> <p>but still is some problems:</p> <ol> <li>can't save circle - <strong>Uncaught TypeError: Cannot read property 'call' of undefined</strong></li> <li>polygon that concatenates to last coordinate (arrow head) doesn't exists in xml, <i>i guess i need somehow merge LineString with Polygon</i></li> <li>i draw element in canvas and placing it on LineString, after convertation to ol.format.KML i receive bad XML where canvas is converted into <code>&lt;href&gt;100&lt;/href&gt;</code> and after reading this part i receive error about URL</li> </ol> </div>

使用AJAX和Symfony 3.x传递post参数时出错

<div class="post-text" itemprop="text"> <p>I want to use Ajax to past POST parameters in one of my controller. </p> <p>For this, i did this code : </p> <pre><code>&lt;script type="text/javascript"&gt; document.getElementById('navbar').style.visibility='hidden'; idacc = $("#idAcc").data(); console.log(idacc); var form = $("#form"); div = form.find("div"); console.log(div); $("#ajax").click(function(div){ $.ajax({ type: "POST", url: "/message/add/" + {{ id }}, data: div, success: function(div){ console.log(div); console.log($(this)); } }); console.log("click"); }); &lt;/script&gt; </code></pre> <p>It's a little script that i've made while i was searching in the web. </p> <p>My html struct is : </p> <pre><code>&lt;div class="form&gt; &lt;div&gt;...&lt;/div&gt; &lt;div&gt;...&lt;/div&gt; &lt;div&gt;...&lt;/div&gt; &lt;div&gt;...&lt;/div&gt; ..... &lt;/div&gt; </code></pre> <p>So with my script, the div variable receive all of the div in the div with the "form" class. It's ok when i dump it in the success function, i have what i want. But when I see in the symfony toolbar POST parameters, there's nothing, i tried to do this as well :</p> <pre><code>data: { 'div': div } </code></pre> <p>I'm getting an error </p> <blockquote> <p>Uncaught TypeError: Cannot read property 'defaultView' of undefined</p> </blockquote> </div>


<div class="post-text" itemprop="text"> <p>I am using the <a href="" rel="nofollow">startbootstrap-clean-blog-1.0.2</a> template as a base for my general project. I am currently making a small list/view application (My first try at such a thing). When i click the 'submit button' in my form, bootstaps validation script for the contact form runs and prevents the form from submitting due to 'indexof' conflicts/errors (if i am guessing correctly)</p> <p>Using Chromes developer tools I found the following error when I click the submit button:</p> <pre><code>Uncaught TypeError: Cannot read property 'indexOf' of undefined (Clean-blog.js:25) $.jqBootstrapValidation.submitSuccess (Clean-blog.js:25) (anonymous function) Clean-blog.js:25 jquery.js:4409 jQuery.event.dispatch (jquery.js:4095) jQuery.event.add.elemData.handle (jquery.js:4095) </code></pre> <p>I've no real understanding of javascript or jQuery, still learning PHP. The errors seem to have something to do with a validation script for the contact form WHICH my list/View page has nothing to with (or so i thought). All I am trying to do is make sure that my form works (When I click the button, it goes to the submitted.php page). How can I get the page to submit?</p> <p>I've seen many posts asking 'how to prevent a submit' but nothing on how to get a form in bootstrap to submit' on stack. </p> <p>This is my code:</p> <pre><code>&lt;form class='' action='sent.php' method='post' name='sendTest'&gt; &lt;ul&gt; &lt;li&gt; &lt;h2&gt;TEST&lt;/h2&gt; &lt;/li&gt; &lt;li&gt; &lt;label for='name'&gt;Name:&lt;/label&gt; &lt;input type='text' name='name' /&gt; &lt;/li&gt; &lt;li&gt; &lt;button type='submit'&gt;Insert Name&lt;/button&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/form&gt; </code></pre> </div>


<div class="post-text" itemprop="text"> <p>what I'm trying to do is, i have a table named hotels and i have a page where peoples can book the hotel based on the room category. now for displaying the hotels I am using a while loop in which datas are fetch and hotels are displayed in automated divs which id same for all. so i added a <code>$i=1</code> and added to the id fields and <code>$i</code> is incremented at the end of the while loop.<br> so what error I am getting is I am not able to retrieve the cost of the room category. </p> <p>here is my code:</p> <p>php code for getting individual hotels and show it in a div.</p> <pre><code>&lt;?php include 'mysql.php'; $i = 1; $query = mysql_query("SELECT * FROM hotels WHERE location = 'portblair' ") or die("the query cannot be completed at this moment"); if(mysql_num_rows($query) &lt;1) { die("no hotels found"); } while($row = mysql_fetch_array($query, MYSQL_ASSOC)){ $hotel_name = $row['name']; $hotel_type = $row['type']; $hotel_location = $row['location']; $hotel_cat1 = $row['cat1']; $hotel_cat2 = $row['cat2']; $hotel_cat3 = $row['cat3']; $hotel_cat4 = $row['cat4']; $hotel_cp = $row['cp']; $hotel_map = $row['map']; $hotel_ap = $row['ap']; $hotel_em = $row['em']; if($hotel_type == "0"){ $hotel_star ='&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;'; } if($hotel_type == "1"){ $hotel_star ='&lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;'; } if($hotel_type == "2"){ $hotel_star ='&lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;'; } if($hotel_type == "3"){ $hotel_star ='&lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;'; } if($hotel_type == "4"){ $hotel_star ='&lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;'; } ?&gt; &lt;div class="col-md-3 col-xs-6"&gt; &lt;div class="panel panel-red"&gt; &lt;div class="panel-heading"&gt; &lt;?php echo $hotel_name; ?&gt; &lt;/div&gt; &lt;div class="panel-body"&gt; &lt;img src="images/hotels/&lt;?php echo $hotel_name ?&gt;.png" class="img-responsive"/&gt; &lt;div class="my-caption"&gt; &lt;?php echo $hotel_star; ?&gt; &lt;/div&gt; &lt;select name="hotel_cat" id="hotel_cat[&lt;?php echo $i; ?&gt;]" class="form-control" onchange="hotel_rate()"&gt; &lt;option value=""&gt;Category&lt;/option&gt; &lt;?php if($hotel_cat1 != ""){ ?&gt; &lt;option value="&lt;?php echo $hotel_cat1; ?&gt;"&gt;&lt;?php echo $hotel_cat1; ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;?php if($hotel_cat2 != ""){ ?&gt; &lt;option value="&lt;?php echo $hotel_cat2; ?&gt;"&gt;&lt;?php echo $hotel_cat2; ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;?php if($hotel_cat3 != ""){ ?&gt; &lt;option value="&lt;?php echo $hotel_cat3; ?&gt;"&gt;&lt;?php echo $hotel_cat3; ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;?php if($hotel_cat4 != ""){ ?&gt; &lt;option value="&lt;?php echo $hotel_cat4; ?&gt;"&gt;&lt;?php echo $hotel_cat4; ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;span id="add[&lt;?php echo $i; ?&gt;]" &gt;Add&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php $i++; } ?&gt; &lt;input type="hidden" name="count" id="count" value="&lt;?php echo $i; ?&gt;"/&gt; </code></pre> <p>so i want a js script that shows the cost of the category of room selected for individual hotels.</p> <p>here is my js code:</p> <p></p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function hotel_rate(){ jQuery(document).ready(function($){ var i=1; var cnt = $("#count").val(); for(i=1;i&lt;cnt;i++){ var cat = $("#hotel_cat["+i+"]").val(); var test = cat.split(:); var cat_cost = parseInt(test[1]); $("#add["+i+"]").html("Rs: "+cat_cost+" Add"); } }); }</code></pre> </div> </div> <p>and the error iam getting from console is: "Uncaught ReferenceError: hotel_rate is not defined" and "Uncaught TypeError: Cannot read property 'split' of undefined".</p> <p>any type of help would be appriciated. thanx in advance.</p> </div>


今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...



和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...



总结了 150 余个神奇网站,你不来瞅瞅吗?



提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...






私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...


场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...


阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...




本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...




当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...


HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...



面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?





已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)


《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)


都前后端分离了,咱就别做页面跳转了!统统 JSON 交互

文章目录1. 无状态登录1.1 什么是有状态1.2 什么是无状态1.3 如何实现无状态1.4 各自优缺点2. 登录交互2.1 前后端分离的数据交互2.2 登录成功2.3 登录失败3. 未认证处理方案4. 注销登录 这是本系列的第四篇,有小伙伴找不到之前文章,松哥给大家列一个索引出来: 挖一个大坑,Spring Security 开搞! 松哥手把手带你入门 Spring Security,别再问密...










不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...


某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...