jquery

return bool from asp.net mvc actionresult

烈酒焚心 提交于 2021-02-17 09:12:13
问题 I submitted a form via jquery, but I need the ActionResult to return true or false. this is the code which for the controller method: [HttpPost] public ActionResult SetSchedule(FormCollection collection) { try { // TODO: Add update logic here return true; //cannot convert bool to actionresult } catch { return false; //cannot convert bool to actionresult } } How would I design my JQuery call to pass that form data and also check if the return value is true or false. How do I edit the code

Does not use passive listeners to improve scrolling performance (Lighthouse Report)

社会主义新天地 提交于 2021-02-17 08:48:13
问题 A recent Lighthouse Report flagged the following issue. Does not use passive listeners to improve scrolling performance It also mentions... Consider marking your touch and wheel event listeners as passive to improve your page's scroll performance. How do I resolve this issue? It appears to be related to jQuery. 回答1: There was a long thread on this topic in https://github.com/jquery/jquery/issues/2871 in 2016 In short: jQuery can't add support to passive listeners. Is expected that this is

jQuery, change separator to dot and divide two selected numbers

跟風遠走 提交于 2021-02-17 07:20:13
问题 var result = parseFloat($('.lot2').text()) / parseFloat($('span.Price').text()); $('.result').text(result); }); How can I convert selected values from comma separated values to dot separated values? There is this function str.replace, but I don't know how to put it in the function. 回答1: How can I convert selected values from comma separated values to dot separated values? From that, I take it that the values you get from $('.lot2').text() and $('span.Price').text() will use , as the decimal

Set a focus on input field after alert in JavaScript error

萝らか妹 提交于 2021-02-17 07:15:44
问题 I want to set focus on a specific input field using JavaScript function. Here is the coding: function checknag() { var x1 = document.getElementById('tsumnag').value; var x2 = document.getElementById('salenugsum').value; if (+x1 == +x2) { // here the button key 'hey' will be used as the text. $('#munshi_perc').focus(); } } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input required class="urdu" onfocusout='checknag();' value="" type="text" />

jquery Use two done callbacks in same function, one with datatype json one without

谁说胖子不能爱 提交于 2021-02-17 06:43:16
问题 Trying to use two done callbacks in a jQuery function. One is a data type JSON, the other is not. The first calls a php function for its data that is not a JSON array. The second I want would call a JSON encoded array from the same php call. I need to pass the array of the ID's to another function Is this possible? Something like this function func1() { jQuery.ajax({ type: 'post', url: my_ajax.ajax_url, data: { action: 'myphp' } }) .done(function(data) { jQuery('#adivID').html(data); }) .fail

how to make a dropdown list using json format compatible with jquery

邮差的信 提交于 2021-02-17 06:42:08
问题 I have the following codes that works successfully with js but don't under jquery (precisely jquery mobile 1.4.5). let me describe it : In js folder I have json list that I put into a function function JsonList(){ var Food = //4 elements json format [ { "name": "Food1", "Glc": 2, "Lip": 0.2, "Prot": 0.5, "IG": 20 }, { "name": "Food2", "Glc": 4, "Lip": 1.2, "Prot": 0.7, "IG": 40 }, { "name": "Food3", "Glc": 5, "Lip": 0.32, "Prot": 0.76, "IG": 60 }, { "name": "food4", "Glc": 7.5, "Lip": 1.5,

include part of a website in my website

坚强是说给别人听的谎言 提交于 2021-02-17 06:39:11
问题 I am trying to find a way to include part of another website in my website. can i do this - im thinking may use an iframe but how can i make it only show say one on the other site. for example, if the other site has: <div id="a_div"> content here </div> <div id="b_div"> other content here </div> how can i include only the *a_div* div on my site so only: content here will display? 回答1: You can't do what you're trying to do, sorry, It's not possible to filter the iframe content. 回答2: You can't,

Submitting Form using jquery AJAX

大城市里の小女人 提交于 2021-02-17 06:05:55
问题 I am trying to submit my form using jQuery ajax, but my data isn't posting to PHP it returns empty array nothing in $_POST array. This is my code - here is my form: <form action = "/webdevelopmentpakistan/send_mail.php" method = "post" class = "myForm" > <div class="row"> <div class="col-md-3 col-sm-12"> <div class="form-group"> <input class="form-control" id="fname" type="text" required name= "full_name" placeholder="Full Name" /> </div> </div> <div class="col-md-3 col-sm-12"> <div class=

jQuery not recognized in extended html python flask

霸气de小男生 提交于 2021-02-17 05:51:10
问题 Not sure what is going on here. It seems that jQuery is not "extended" from a base.html file to an external one. I have: #base.html <!doctype html> <html class="no-js" lang="en"> <head> ... ... # css imports </head> <body> # some fixed stuff {% block body %} # some stuff specific to base.html {% endblock %} # js imports at the end of the body <script src="static/js/jquery-3.1.0.min.js"></script> ... # various other js </body> </html> Then I have another html file: #test.html {% extends "base

jquery selectedIndex doesn't work

六眼飞鱼酱① 提交于 2021-02-17 05:40:07
问题 i have a from with many select tags , when the user submit the form i want to check if the user choose one option for all the select tags and this is my jquery code $('#apForm select').each(function(){ var $this = $(this); if ($this.selectedIndex == 0){ var error = 'fill this please' ; $this.next('span').text(error); errorCount = errorCount + 1; } }); and i tried like this $this.attr("selectedIndex") i just give you the piece of my code where my question is if i should give more code tell me