Non-flush asynchronous transmission of Ajax JSON data for jquery Ajax instances

Source: Internet
Author: User

In the background of their own CMS, want to be on the same page with a pop-up mask layer of the way to modify member information

Getting userid is a big problem.

Last colleague's advice with $.ajax

The code is as follows Copy Code

$ (' p.editinfo>a '). Bind (' click ', function () {
$ (' #edit_uid '). Val ($ (this). attr ("UID"));
Alert ($ (this). attr ("UID"));
var uid= $ (this). attr ("UID");
alert (vote_content);
$.ajax ({
Type: ' Get ',
DataType: ' JSON ',
URL: ' user_edit.php ',
Data: ' uid= ' + uid,
Success:function (JSON) {
$ (' #username '). Val (Json.username); Assign a value to a corresponding JOSN value
$ (' #mid_1 '). Val (Json.mid);
$ (' #new_password '). Val (Json.password);
$ (' #uid_edit '). Val (Json.uid);
},
Error:function () {}
});
});
});


The user_edit.php used to receive is the normal PHP SQL statement
Use the Json_encode function (refer to Php-json_encode)

The code is as follows Copy Code

$uid = $_get[' uid '];
$query _admin_1 = $db->find ("table where uid= ' $uid ')";
$row _admin_1 = $db->fetch_array ($query _admin_1);
$userinfo = Json_encode ($row _admin_1);
Echo $userinfo;


The resulting $userinfo for JSON data storage format

A standard HTML form that receives JSON data

  code is as follows copy code

        <div class= "txt-fld"
               <label for= "" > User name </label>
               <input id= "username" class= "good_input" name= "username" type= "text"
              </div>
              <div class= "txt-fld"
             <label for= "" > User password/label>
            <input id= "New_password" name= "new_password" type= "password"    />
      </div>

Note that the Ajax operating part is not quite the same as it is, only in datatype: ' JSON ', and then we access the content in Json.mid this form, in fact, like the array $a[' a ', where JSON is a returned array, Mid is the ID we returned.

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.