jquery passes value to PHP

Source: Internet
Author: User
How do I pass the value in jquery to PHP in the current page (without refreshing the page)? , please give me a sample code.


Reply to discussion (solution)

$.ajax ({url: "test.php", Context:document.body, Success:function () {
$ (this). AddClass ("Done");
}});

$.post ("btdz.php", {title:i,action:1},function (data) {
alert (data);
});
})

Not refreshing is not possible, local refresh.
Set up two pages for a.php and b.php, respectively
a.php

 
  
 
  


b.php
 
  

I wrote to someone before. A registration page: http://bbs.csdn.net/topics/390398302, the 17 floor.

Thank you, I'm not clear about the problem, I mean refresh the contents of a local div in the page based on the new value of the variable

JS Dom operation is possible.
var s= ' xxxx ';
document.getElementById (' div '). Innerhtml=s;

Thank you, I'm not clear about the problem, I mean refresh the contents of a local div in the page based on the new value of the variable

I don't know what that means.

Landlord may be your idea of the starting point there is a problem.

First, PHP is a server-side scripting language, and the pages you get are static HTML pages that have been parsed by the PHP server.

If you want to implement the content of the page without flushing, you can asynchronously want PHP to send the request to get the data and then use jquery to manipulate the DOM.

It is not possible to pass a jquery variable value to PHP on the current page without going through the server.

Thank you, knot-stickers.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.