jQuery - AJAX post() 问题
<!DOCTYPE html>
<script src="http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js">
      name:"Donald Duck",
      alert("数据:" + data + "\n状态:" + status);

<button>向页面发送 HTTP POST 请求,并获得返回的结果</button>


-------以上代码点击按钮无反应,但是复制到:http://www.w3school.com.cn/tiy/t.asp?f=jquery_ajax_post 在线测试又可以,什么原因呢?请高手指点!!


控制器设置 允许外部资源访问
response.setHeader("Access-Control-Allow-Origin", "*");

lijun624wll 谢谢,已经搞定了!
2 年多之前 回复


支付宝加好友偷能量挖 回复lijun624wll: 提供jsonp格式数据,不知道jsonp自己找资料看。或者服务器添加Access-Control-Allow-Origin响应头为*允许跨域请求,但是IE10-有兼容性问题,要用XDomainRequest对象请求
2 年多之前 回复
lijun624wll 那么如果我跨域怎么操作呢?我写了一个webservice别人怎么通过js post提交数据并得到返回数据呢?
2 年多之前 回复


经核实对方的数据安徽 百度一下你就知道
7 个月之前 回复
lijun624wll 那么如果我跨域怎么操作呢?我写了一个webservice别人怎么通过js post提交数据并得到返回数据呢?
2 年多之前 回复




  1. jsonp处理,需要提供接口方提供跨域支持,你可以看看jquery就有jsonp的请求方法。
  2. cors跨域处理,需要提供接口方提供跨域支持,你可以正常post请求,只是后台添加请求头


所用的 getPreventDefault() 已不赞成使用。请改用 defaultPrevented。
已拦截跨源请求:同源策略禁止读取位于 http://www.w3school.com.cn/example/jquery/demo_test_post.asp 的远程资源。(原因:CORS 头缺少 'Access-Control-Allow-Origin')。

把这个资源 http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js 下载到本地才行。

Csdn user default icon
admin-ajax.php POST 500在WordPress中的问题

<div class="post-text" itemprop="text"> <p>I have a problem with my WordPress I can't update the product in Quick editing when click on update button Circle just spins </p> <pre><code>load-scripts.php?c=0&amp;load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-draggable,jquery-ui-position,utils&amp;ver=4.9.8:4 </code></pre> <p>POST <code>https://novinelc.com/wp-admin/admin-ajax.php 500</code> in <code>wp-config</code> set php <code>memory on 256</code></p> </div>


<div class="post-text" itemprop="text"> <p>This might be easy but I'm having trouble doing this right. How can I open a new page in the same window using jquery-ajax response?</p> <p>As you can see I'm trying to display a custom text if the php response is equal to the word "invalid". If not open a new html page in the same window.</p> <pre><code> $("#lBtn").click(function(){ $.post("php/session.php", { username:$("#username").val(), password:$("#password").val() }, function(response) { alert(response) if(response == "invalid"){ $("#loginResponse").text("Error!!"); } else { window.location = $(this).find('new/pahe.html').html(); } }); }); </code></pre> <p>Alert(response) shows the word "invalid" but the if statement does not work. Means neither it display <code>Error!!</code> in <code>$("#loginResponse")</code> nor it opens the new page. That's what I want to fix.</p> </div>


<div class="post-text" itemprop="text"> <p>I have a form made with multipage Gravity Form with Ajax enabled in Wordpress.</p> <p>Since it is not possible to clone the fields that must have a unique ID, for me it is necessary to insert a field on each page that, if modified, sets the value equal to the other fields of the other pages.</p> <p>The script works in multipage but not with the Ajax option enabled. Ajax is necessary for not completely reload the page but only the form because in the page I have third-party information in a iframe that does not need to be updated.</p> <p>How can I resolve this conflict?</p> <p>Thanks</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function(){ jQuery('#input_3_4').on('change',function(){ var info = jQuery('#input_3_4').val(); alert(info); $('#input_3_6').val(info); $('#input_3_7').val(info); }); jQuery('#input_3_6').on('change',function(){ var info = jQuery('#input_3_6').val(); alert(info); $('#input_3_4').val(info); $('#input_3_7').val(info); }); jQuery('#input_3_7').on('change',function(){ var info = jQuery('#input_3_7').val(); alert(info); $('#input_3_4').val(info); $('#input_3_6').val(info); }); }); &lt;/script&gt;</code></pre> </div> </div> </div>

使用 PHP 实现 jQuery Ajax POST 示例

<div class="post-text" itemprop="text"> <p>I am trying to send data from a form to a database. Here is the form I am using:</p> <pre><code>&lt;form name="foo" action="form.php" method="POST" id="foo"&gt; &lt;label for="bar"&gt;A bar&lt;/label&gt; &lt;input id="bar" name="bar" type="text" value="" /&gt; &lt;input type="submit" value="Send" /&gt; &lt;/form&gt; </code></pre> <p>The typical approach would be to submit the form, but this causes the browser to redirect. Using jQuery and <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">Ajax</a>, is it possible to capture all of the form's data and submit it to a PHP script (in example, <em>form.php</em>)?</p> </div> <p>转载于:https://stackoverflow.com/questions/5004233/jquery-ajax-post-example-with-php</p>

POST /wp-admin/admin-ajax.php 400(错误请求)

<div class="post-text" itemprop="text"> <p>I have written a jQuery function using jsPDF to convert a form to PDF, I have then added an ajax command with the intention of saving the generated PDF to the server. However, when I click submit, the page appears to be completing an action. but, when I look at console I see:</p> <blockquote> <p>POST website.com/wp-admin/admin-ajax.php 400 (bad request)</p> </blockquote> <p>and I cannot figure out where my code has went wrong.</p> <p>I have registered my JS and used <code>wp_localize</code> in functions.php:</p> <pre><code>function ASAP_scripts() { wp_register_script('js-pod', get_stylesheet_directory_uri() . '/js/POD.js', array('jquery'),'1.1', true); wp_enqueue_script('js-pod'); wp_localize_script( 'js-pod', 'jspod', array( 'ajax_url' =&gt; admin_url( 'admin-ajax.php' ) ) ); } add_action( 'wp_enqueue_scripts', 'ASAP_scripts' ); </code></pre> <p>I have also added my ajax commands again in functions.php</p> <pre><code>add_action( 'wp_ajax_my_ajax_request', 'so56917978_upload_callback' ); add_action( 'wp_ajax_nopriv_my_ajax_request', 'so56917978_upload_callback' ); function so56917978_upload_callback() { if ( ! empty( $_POST['data'] ) ) { $data = base64_decode($_POST['data']); file_put_contents( "get_stylesheet_directory_uri() . '/POD/pod.pdf' ", $data ); echo "success"; } else { echo "No Data Sent"; } die; } </code></pre> <p>My jQuery:</p> <pre><code>function sendToServer() { html2canvas(document.getElementById("product_sheet"), { onrendered: function(canvas) { console.log("#submit clicked"); var img = canvas.toDataURL("image/png"); var doc = new jsPDF('p', 'pt', 'a4'); doc.addImage(img, 'JPEG',20,20); var file = doc.output('blob'); var pdf = new FormData(); // To carry on your data pdf.append('mypdf',file); $.ajax({ url: '/wp-admin/admin-ajax.php', //here is also a problem, depends on your data: { action: 'so56917978_upload', // Action name. data: pdf, }, dataType: 'text', processData: false, contentType: false, type: 'POST', }).done(function(data){ console.log(data); }); } }); } </code></pre> <p>Any help in solving this would be great. I have seen similar questions on here but I feel as though I have covered all the bases which they discuss and genuinely cannot see my issue</p> <p>Update...</p> <p>Update...</p> <p>I have changed MY JS slightly, it seems to work better and more as expected, however, I am still getting `no data sent. So the ajax request seems to be working. but, it appears that there may be something in the PHP which is stopping it from completing?</p> <p>JS</p> <pre><code>function sendToServer() { html2canvas(document.getElementById("product_sheet"), { onrendered: function(canvas) { console.log("#pdfsubmit clicked"); function html() { var img = canvas.toDataURL("image/png"); var doc = new jsPDF('p', 'pt', 'a4' ); doc.addImage(img, 'JPEG', 20, 20); var pdf = doc.output('blob'); $.ajax({ url: jspod.ajax_url, type: 'post', async: false, contentType: 'application/json; charset=utf-8', data:{ data: pdf action:'so56917978_upload' }, dataType: 'json' }); } }); } } </code></pre> <p>PHP:</p> <pre><code>add_action( 'wp_ajax_so56917978_upload', 'so56917978_upload' ); add_action( 'wp_ajax_nopriv_so56917978_upload', 'so56917978_upload' ); function so56917978_upload() { if ( ! empty( $_POST['action'] ) ) { $data = base64_decode($_POST['action']); file_put_contents( get_template_directory() . '/POD/pod.pdf' , $data ); echo "success"; } else { echo "No Data Sent"; } die(); } </code></pre> </div>

Phalcon jquery-ajax按钮点击

<div class="post-text" itemprop="text"> <p>I am warking in phalcon framework, and i am trying to call controller's method to get simple string using jquery-ajax. When i placed my ajax call inside $(document).ready(function() ajax call worked, but when i placed same code inside $('#dugme').click(function() ajax call reported error. I am confused. Here is my view code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ //alert($("#nesto").val()); //atr = $(".klasa").attr("id"); //alert("Id je: " + atr) $.ajax({ url: '&lt;?php echo $this-&gt;url-&gt;get("xml/posalji");?&gt;', type: 'POST', dataType: 'json', success: function(data){ alert(data); }, error: function(){ alert("Neuspjesan JSON zahtjev!"); } }); $('#dugme').click(function(){ $.ajax({ url: '&lt;?php echo $this-&gt;url-&gt;get("xml/posalji");?&gt;', type: 'POST', dataType: 'json', success: function(data){ alert(data); }, error: function(){ alert("Neuspjesan JSON zahtjev!"); } }); }) ; }); &lt;/script&gt; &lt;h2&gt;Basic example&lt;/h2&gt; &lt;?php echo Tag::form("xml/pretraga"); ?&gt; &lt;p&gt; &lt;label for="name"&gt;Title&lt;/label&gt; &lt;?php $opt = array('title', 'id'=&gt;'nesto', 'size'=&gt;'10'); $buttopt = array('Show', 'id'=&gt;'dugme','class'=&gt;'klasa'); ?&gt; &lt;?php echo Tag::textField($opt) ?&gt; &lt;/p&gt; &lt;p&gt; &lt;?php echo Tag::SubmitButton($buttopt) ?&gt; &lt;/p&gt; &lt;/form&gt; </code></pre> <p>and here is my action code:</p> <pre><code> public function posaljiAction(){ $this-&gt;view-&gt;disable(); $data = "My name is Nedimo"; echo json_encode($data); } </code></pre> <p>Please, can anyone tell me what is wrong in my code.</p> </div>

等待所有 jQuery Ajax 请求完成?

<div class="post-text" itemprop="text"> <p>How do I make a function wait until all jQuery Ajax requests are done inside another function?</p> <p>In short, I need to wait for all Ajax requests to be done before I execute the next. But how?</p> </div> <p>转载于:https://stackoverflow.com/questions/3709597/wait-until-all-jquery-ajax-requests-are-done</p>


<div class="post-text" itemprop="text"> <p>Im looking for a little help on getting my JQuery/Ajax call to return a List from a Struts action and populate a DIV with the list elements using s:iterator.</p> <p>I have the following JQuery</p> <pre><code> function lookupCustomerJs() { alert("lets start"); $.ajax({ type: "POST", url: "lookupCustomerAjax", data: $('#lookupCustomer').serialize(), success:function(response) { alert("do stuff"); $('div#custList').replaceWith($(response).find("div#custList")); }, failure:function(response) { alert('Ajax call failed'); }, error:function(response) { alert(exception); } }); } </code></pre> <p>I have a DIV within my page which I then want to iterate the list through</p> <pre><code> &lt;div id="custList"&gt; &lt;s:iterator status="stat" value="customerList" var="customer"&gt; &lt;s:param name="custFName" value="%{customer.firstname}" /&gt; &lt;/s:iterator&gt; &lt;/div&gt; </code></pre> <p>And my Action method which IS called, because when I debug, the debugger goes through the code.</p> <pre><code>private List&lt;Customer&gt; customerList; public String lookupCustomerAjax() { dummyData(); return SUCCESS; } </code></pre> <p>This successully calls my Action method, but all I get is the "lets start" alert, then nothing else, no errors, nothing!</p> <p>So I'm guessing it's just the jQuery/Ajax success:function(response) { not fireing correctly, but can't see why.</p> </div>


<div class="post-text" itemprop="text"> <p>I have two input elements in my page.</p> <pre><code>&lt;input type="button" id=" MyButton" onclick="SomeFunction()" value="click me" /&gt; &lt;input type="text" id="text" /&gt; </code></pre> <p>I'm trying to get "Hello World" text from my <code>a1.ph</code>p using jQuery ajax, but I'm getting error, which says :</p> <blockquote> <p>Network Error: Failed to execute 'send' on XMLHttpRequest: Failed to load 'file:///C:/a1.php'</p> </blockquote> <p>Here's my javaScript function:</p> <pre><code>function SomeFunction() { //alert("AAAAAAAAAA"); jQuery("#text").val("AAA"); jQuery.ajax({ type: "GET", url: "a1.php", success: function() { alert("OK"); }, error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); } </code></pre> <p>Please help me to fix this little problem.</p> </div>

为什么我在用Ajax 和jquery方式实现登录名验证时,只有jquery-1.8.2.js管用

<script type="text/javascript" src="<%=path%>/js/jquery-1.8.2.js"></script> 可以 <script type="text/javascript" src="<%=path%>/js/jquery-1.8.3.js"></script> 不可以 <script type="text/javascript" src="<%=path%>/js/jquery-1.9.1.js"></script> 不可以 <script type="text/javascript" src="<%=path%>/js/jquery-1.11.1.js"></script> 不可以


<div class="post-text" itemprop="text"> <p>Studying the following ajax request, I was wondering:</p> <ul> <li>What advantages can a non-async ajax call achieve?</li> <li><p>What is the <code>.responseMessage</code> good for, what does it store?</p> <pre><code> var myTemplate = $.ajax({ type: "GET", url: "myurl.html", async: false, cache: false }).responseMessage; </code></pre></li> </ul> </div>


<div class="post-text" itemprop="text"> <p>I've written a jQuery-AJAX function as follows :</p> <pre><code>$('#request_form').submit(function(e) { var form = $(this); var stud_id = $('#stud_id').val(); var reg_date = $('#reg_date').val(); var formdata = false; var fileInput = $("#receipt_image")[0]; /*I want to pass values of below variables to the PHP file.*/ var ImgSizeInBytes = fileInput.files[0].size; var filename = $('input[type=file]').val().split('\\').pop(); var customer_id = $('#customer_id').val(); /*These values need to send to PHP file and access there */ if(window.FormData) { formdata = new FormData(form[0]); } var formAction = form.attr('action'); $.ajax({ url : 'student_request.php', type : 'POST', cache : false, data : formdata ? formdata : form.serialize(), contentType : false, processData : false, success: function(response) { var responseObject = $.parseJSON(response); if(responseObject.error_message) { if ($(".alert-dismissible")[0]) { $('.alert-dismissible').remove(); } var htmlString = "&lt;div class='alert alert-danger alert-dismissible' role='alert'&gt;&lt;button type='button' class='close' data-dismiss='alert' aria-hidden='true'&gt;&amp;times;&lt;/button&gt;"+responseObject.error_message+"&lt;/div&gt;"; $(htmlString).insertBefore('div.modal-body #request_form'); } else { alert("Student successfully registered...!!!"); } } }); e.preventDefault(); }); </code></pre> <p>Now I'm able to access the values filled in by user on a form by means of <code>$_POST</code> array in PHP file. But I also want to pass the values I put in comment in my code above to the PHP file.</p> <p>The values/parameters which I want to send are not part of a form fields. I've manipulated the values of these variables. So they can't come in <code>$_POST</code> array.</p> <p>My issue is how should I send these values to PHP file and how should I access these values in PHP file?</p> </div>

jquery - ajax - 逐个更新列的问题

<div class="post-text" itemprop="text"> <p>i want to update each columns acording by id, when i click on an image, without refresh all the page. my codes just update last ids column when i click each on images.<br> index.php:</p> <pre><code>$rzp=mysqli_query($conn,"SELECT * FROM `tbl_users_posts` WHERE uid=1"); while($rw=mysqli_fetch_assoc($rzp)){$id=$rw['id']; echo $id;?&gt;&lt;img id="up" src="pc3/up.png" alt=""&gt;&lt;br&gt; &lt;?php }?&gt; &lt;script&gt; $(document).ready(function() { var id = &lt;?php echo $id;?&gt;; $(document).on("click","#up",function() { $.ajax({ method: "POST", url: "y2.php", data: {id: id}, async :false }).done(function(msg2) { alert(msg2); }); }); }); &lt;/script&gt; </code></pre> <p>y2.php:</p> <pre><code>$id=$_POST['id']; mysqli_query($conn,"UPDATE `tbl_users_posts` SET lik=lik+1 WHERE id='$id'"); </code></pre> <p>thanks</p> </div>


<div class="post-text" itemprop="text"> <p>I'm using the following code to have multiple ajax requests like this:</p> <p>request <strong>1 start</strong> | request <strong>1 finish</strong> | request <strong>2 start</strong> | request <strong>2 finish</strong> | ...</p> <p>This is the code:</p> <pre><code>var startingpoint = fireRequest(1); $.each(types,function(ix,type) { startingpoint = startingpoint.pipe( function() { alert(startingpoint.status); // undefined return fireRequest(type); }); }); </code></pre> <p><strong>fireRequest</strong> is just a switchcase to the correct ajax function which returns $.ajax(...)</p> <p>I'd like the chain to stop when one request fails. I started implementing it and as a test I'd like to alert the status of the ajax object, but it shows 'undefined'. How can I get the status?</p> </div>

jQuery 的ajax POST提交不了数据?

现在手jQuery和struts 如下的提交方法,在action中,所有的form表单都取不到,全为null 参数放在url后面的话可以取到 这是什么原因?? [code="javascript"] $.ajax({ url: 'lomcItemAE.do', type: 'POST', timeout: 30000, error: function(){ alert('Error loading XML document'); }, success: function(xml){ alert(xml); $(xml).find("model").each(function(i){ alert($(this).text()); }); } });[/code] [b]问题补充:[/b] 用的是form ,不是<html:form> 而且 form 里也写了action 还有个jquery 读XML在IE与FF下不一致


<div class="post-text" itemprop="text"> <div class="question-status question-originals-of-duplicate"> <p>This question already has an answer here:</p> <ul> <li> <a href="/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call" dir="ltr">How do I return the response from an asynchronous call?</a> <span class="question-originals-answer-count"> 35 answers </span> </li> </ul> </div> <p>I have created a page with Ajax function (jQuery &amp; PHP). My problem is when I load content via Ajax in my page. I want to read width of images placed inside of Ajax-container.</p> <p>I noticed something quite remarkable.</p> <p>My script:</p> <pre><code>&lt;script&gt; $(window).ready(function () { var bildBreite = $("#wrapper &gt; #target-image").width(); alert(bildBreite); $("#wrapper &gt; #image-wrapper").css({"width": bildBreite}); }); &lt;/script&gt; </code></pre> <p>It does not work, but when I insert alert ("load"); then work it.</p> <pre><code>&lt;script&gt; $(window).ready(function () { alert("Load"); var bildBreite = $("#wrapper &gt; #target-image").width(); alert(bildBreite); $("#wrapper &gt; #image-wrapper").css({"width": bildBreite}); }); &lt;/script&gt; </code></pre> <p>What happens here, how can I read the image width?</p> </div>


<div class="post-text" itemprop="text"> <p>Refer to the following code, this script doesn't post the "limit" variable to the next page</p> <p>MY JS Code:</p> <pre><code>$(document).ready(function(){ $(window).scroll(function() { if ($('body').height() &lt;= ($(window).height() + $(window).scrollTop())) { var dataString="2"; $.ajax({ type:"POST", url: "load_data.php", data: { 'limit': dataString }, success:function(data) { $('#leftNews').load('load_data.php'); } }); } }); }); </code></pre> <p>PHP CODE</p> <pre><code>&lt;?php if(isset($_POST['limit'])) { echo $_POST['limit']; } else echo 'asd'; ?&gt; </code></pre> <p>Everytim i run this i get "asd" printed</p> </div>


<div class="post-text" itemprop="text"> <p>I'm currently working on a WordPress contact form, which is created as a plugin. I need the form after submit to send an email without reloading the page. When it reloads everything is ok. The problem is when submit button is pressed and e.preventDefault() is active the browser shows me <strong>500 (Internal Server Error)</strong> with <strong>admin-ajax.php = 0</strong></p> <p>P.S The post is edited</p> <pre><code> &lt;?php add_action( 'admin_footer', 'html_form_code' ); // Write our JS below here // function html_form_code() { ?&gt; &lt;form action="&lt;?php esc_url( $_SERVER['REQUEST_URI'] )?&gt;" method="post" class="contact-form" id="contact-form" &gt; &lt;div class=header-contact&gt; &lt;p&gt;&lt;h2&gt;Contact Form&lt;/h2&gt;&lt;/p&gt; &lt;hr&gt; &lt;/div&gt; &lt;div class=input-containers&gt; &lt;input type="text" id="name" name="cf-name" pattern="[a-zA-Z0-9 ]+" value="" size="40" placeholder="Име и фамилия"/&gt; &lt;/div&gt; &lt;div class=input-containers&gt; &lt;input type="email" id="email" name="cf-email" value="" size="40" placeholder="Поща"/&gt; &lt;/div&gt; &lt;div class=input-containers&gt; &lt;input type="text" id="subject" name="cf-subject" pattern="[a-zA-Z ]+" value="" size="40" placeholder="Относно"/&gt; &lt;/div&gt; &lt;div class=input-containers&gt; &lt;textarea rows="10" id="message" cols="35" name="cf-message" placeholder="Текст"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div class=input-containers&gt; &lt;input type="submit" name="cf-submitted" value="Send" id="submitForm"&gt; &lt;/div&gt; &lt;p id="verify" style="display:none;"&gt;Your message has been sent.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;/form&gt; &lt;script&gt; jQuery('#contact-form').submit(function(e){ e.preventDefault(); var name = jQuery('#name').val(); var email = jQuery('#email').val(); var subject = jQuery('#subject').val(); var message = jQuery('#message').val(); jQuery.ajax({ url: '&lt;?php echo admin_url('admin-ajax.php'); ?&gt;', type: "POST", data:{ action: 'send_email', name: name, email: email, subject: subject, message: message, }, success:function(res){ alert("Email Sent."); } }); }); &lt;/script&gt; &lt;?php } add_action( 'wp_ajax_send_email', 'deliver_mail' ); add_action( 'wp_ajax_nopriv_send_email', 'deliver_mail' ); function deliver_mail() { require_once "wp-includes/class-phpmailer.php"; if (isset($_POST["cf-submitted"])) { // sanitize form values $name = sanitize_text_field( $_POST["cf-name"] ); $email = sanitize_email( $_POST["cf-email"] ); $subject = sanitize_text_field( $_POST["cf-subject"] ); $message = esc_textarea( $_POST["cf-message"] ); // get the blog administrator's email address //$to = "email@gmx.com"; $headers = "From: $name &lt;$email&gt;" . " "; // Localhost $mail = new PHPMailer(true); $mail-&gt;IsSMTP(); // telling the class to use SMTP $mail-&gt;CharSet = 'UTF-8'; $mail-&gt;SMTPDebug = 0; // enables SMTP debug information (for testing) $mail-&gt;SMTPAuth = true; // enable SMTP authentication $mail-&gt;SMTPSecure = "ssl"; // sets the prefix to the servier $mail-&gt;Host = "mail.gmx.com"; // sets GMX as the SMTP server for example: mail.gmx.com $mail-&gt;Port = 465; // set the SMTP port for the GMX server $mail-&gt;Username = $email; $mail-&gt;Password = 'pass'; $mail-&gt;SetFrom($email, $name); $mail-&gt;AddAddress($email); $mail-&gt;Subject = $subject; $mail-&gt;MsgHTML($message); $headers .= "Content-Type: text/html; charset=utf-8"; $headers .= "Content-Transfer-Encoding: 8bit"; try { $mail-&gt;send(); $msg = "An email has been sent for verfication."; $msgType = "success"; wp_safe_redirect( home_url(), 302 ); exit(); } catch (Exception $ex) { $msg = $ex-&gt;getMessage(); $msgType = "warning"; wp_safe_redirect( home_url(), 302 ); exit(); } add_action( 'init', function() { if ( ! empty( $_POST['form_submitted'] ) ) { deliver_mail(); } }); function cf_shortcode() { ob_start(); //deliver_mail(); html_form_code(); //ob_end_flush(); return ob_get_clean(); } add_shortcode( 'contact_form_second', 'cf_shortcode' ); </code></pre> </div>

jquery ajax请求 post 参数问题?

![图片说明](https://img-ask.csdn.net/upload/201702/11/1486777322_515993.png) 其中传递参数requestData 如果这个参数是requestData = {"login_name":"name"}:这样的写法 请求没有问题,php也能够获取到值 但是如果用jquery serializeArray 然后转换成json格式 则返回的是当前页面的html ,不是预先设定的值


大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...


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



技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

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


“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...


loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...






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






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




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

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

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


不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...






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


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



你打算用Java 8一辈子都不打算升级到Java 14,真香



编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

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





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



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


一文带你入门Java Stream流,太强了

两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:“就想看你写的啊!”你看你看,多么苍白的喜欢啊。那就“勉为其难”写一篇吧,嘻嘻。 单从“Stream”这个单词上来看,它似乎和 java.io 包下的 InputStream 和 OutputStream 有些关系。实际上呢,没毛关系。Java 8 新增的 Stream 是为...