ajax

pass Javascript array to PHP using AJAX

≡放荡痞女 提交于 2021-01-27 16:41:58
问题 I have to pass Javascript array variable to PHP , so here php and javascript code both are in same page . when i give console inside isset($_POST['kvcArray'])) -- > it is not printing . guess some problem with this . Can anyone help me in this body { color: #566787; background: #f5f5f5; font-family: 'Varela Round', sans-serif; font-size: 13px; } .table-wrapper { background: #fff; padding: 20px 25px; margin: 30px 0; border-radius:1px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.247); } .table-title

Move coupon form before payment section in WooCommerce checkout

和自甴很熟 提交于 2021-01-27 16:10:31
问题 I would like to move the coupon field at checkout to the woocommerce_review_order_before_payment hook. Having the coupon field at the top of the page negatively affects conversions as users immediately try looking for a coupon code and abandon checkout if they fail to find one. I read online that it's not that simple because the coupon field is also a form. And placing the coupon field anywhere inside the checkout form causes the "Apply Coupon" to submit the order form instead of applying the

Send Angular $http.delete with body

不羁岁月 提交于 2021-01-27 14:30:35
问题 In my Angular app, I need to send an $http.delete request this route /projects/:id/activityTypes (note it does not end with an activity type id) passing a body with the following format: [{"id": 2}] This is to allow batch delete operations by sending multiple objects within the array. Testing the route above with Rest Web Service Client I get a 200, OK status so the route is already implemented and working fine, I just need to implement it in my Angular app. Now, I've checked this previous

Page_Load is been fired when WebMethod is called through javascript PageMethods

房东的猫 提交于 2021-01-27 14:20:35
问题 I have an aspx page. I've added a ScriptManager to it, and set EnablePageMethods=true , and created a static method marked as [WebMethod] on the server-side. I have always worked with WebMethods, and I've never seen this error before. On javascript, PageMethods is accessible. But when I call my method, the Page_Load method is fired, instead of the WebMethod. I've searched and found other people had this issue as well. But no answers.... Any ideas? HTML: <body> <form id="form1" runat="server">

Reload Masonry Grid after AJAX call

痴心易碎 提交于 2021-01-27 14:07:11
问题 I have a Masonry Grid that is working beautifully. It loads perfectly and readjusts. But I am using a plugin that filters results (Search & Filter plugin for Wordpress) and uses AJAX to do that. But after the AJAX call, my masonry grid is no longer working. I know it is due to the fact that I need to reload Masonry after the AJAX call, but I don't exactly know how to do that. Does anyone know how I can do that? Here is my basic HTML structure. <div id="masonry-container> <div id="search

Fastest way to check connection status from browser

こ雲淡風輕ζ 提交于 2021-01-27 13:39:32
问题 I'm using web app from which i send data to server very frequently. Option for sending data should be disabled if app has no internet connection. Which is the fastest way to check from browser if you are online? I've used navigator.onLine but it's unreliable because different browsers interpret it differently. My other solution was to put some plain file on server and attemp to reach it every time before sending. Code looked like this: function serverReachable() { var x = new XMLHttpRequest (

Detect Ajax in PHP

China☆狼群 提交于 2021-01-27 13:05:13
问题 I am trying to make an ajax post to the same php page. Ajax: $("#loginForm").submit(function(e) { e.preventDefault(); var postData = $(this).serialize(); $.post("login.php", postData); }); The postData is correct and is in the following format: username=john&password=123123 PHP (same page): if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { echo 'Ajax Request Detected'; } However this if-check always returns false and the echo

Sending ajax when user closes browser window [duplicate]

試著忘記壹切 提交于 2021-01-27 12:43:58
问题 This question already has answers here : JavaScript, browsers, window close - send an AJAX request or run a script on window closing (9 answers) Closed 4 years ago . My Main GOAL and actual scenario: If two users share the same credentials, then the second user can not login into the system until the first one who is already logged in, log outs system. Actually I want to set login_flag=0 on server database, when user closes the browser window. I googled and figured out to send an ajax request

Drupal 8 add ajax form element after ajax callback

时光怂恿深爱的人放手 提交于 2021-01-27 11:43:37
问题 I am building a drupal form with multiple ajax enabled form elements. I have one select list that does an ajax callback after change. The problem is that it adds a new select list to the page, which is also ajax enabled. This does not seem to work, which seems logical to me because the ajax is actually bundled an added to the page so it is lost in the replacecommand. Is there anyone experienced with this, and does anyone have a solution ? This is my code /** * {@inheritdoc} */ public function

Mathjax not rendering TEX formulas dynamically from PHP/Ajax

帅比萌擦擦* 提交于 2021-01-27 11:41:38
问题 var questions = {"ques_id":"1","question":"<p><span class=\\\"math-tex\\\">\\\\(x = {-b \\\\pm \\\\sqrt{b^2-4ac} \\\\over 2a}\\\\)<\/span>   Test Question new with mathjax<\/p>","ques_type":"text_based_questions","correctAnswer":3,"choices":[{"option_id":"1","value":"Option A"},{"option_id":"2","value":"Option B"},{"option_id":"3","value":"Option C"},{"option_id":"4","value":"OPtion D"}]}; $('#test-question').html(questions.question); MathJax.Hub.Queue(["Typeset",MathJax.Hub, 'test-question']