JQuery Ajax datatype value for text JSON explore sharing _jquery

Source: Internet
Author: User
Copy Code code as follows:

<dt style= "margin:15px 0px 3px; padding:0px; border:0px; Font-weight:bold; Color:rgb (4,121,167); Font-family:verdana,arial, song body; Background-color:rgb (249,249,249) ">datatype
Type: String
The type of data expected to be returned by the server. If not specified, JQuery will automatically intelligently judge against HTTP Packet MIME information, such as XML
MIME types are recognized as XML
</dt><dt style= "margin:15px 0px 3px; padding:0px; border:0px; Font-weight:bold; Color:rgb (4,121,167); Font-family:verdana,arial, song body; Background-color:rgb (249,249,249) ">
</dt>

Copy Code code as follows:

<script type= "Text/javascript" src= ' jquery-1.8.2.min.js ' ></SCRIPT>
<script type= "Text/javascript" >
function text () {
Alert ($ ("input[name= ' text ']"). Val () + "aaaaaaaaa");
Post Pass Value
$.post (
"index.php",//quotes can not forget to add
{
val:$ ("input[name= ' text ')"). Val ()
},
function (data) {
if (data== ' 1 ') {
Alert ("This is the text pass value \ nthe value is passed over is" +data);
}
},
"Text"/quotation marks cannot be forgotten plus
)
}

function json () {
Get Pass Value
$.get (
"Index1.php",
{
val:$ ("Input[name= ' json ')"). Val ()
},
function (data) {
if (data== ' 1 ') {
Alert ("This is the JSON pass value \ n value is" +data);
}
},
' JSON '
)
}

</SCRIPT>
<body>
<input type= ' txt ' name= ' text ' id= ' text ' onblur= ' text () '/><span>datatype value is text</span><br>
<input type= ' text ' name= ' json ' onblur= ' json () ' ><span>datatype value is json</span><br/>
</body>

index.php Code
Copy Code code as follows:

<?php
echo "1";
?>

index1.php Code
Copy Code code as follows:

<?php
ECHO Json_encode ("1");
?>
Related Article

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.