Jquery dialog webwebservice asynchronous call code

Source: Internet
Author: User

The jquery dialog webwebservice asynchronous call code. This section mainly uses the asynchronous call code of jquery + webserver.

The jquery dialog webwebservice asynchronous call code. This section mainly uses the asynchronous call code of jquery + webserver.

<% @ Page language = "c #" autoeventwireup = "true" codefile = "default. asp tutorial x. cs" inherits = "test_jquery_dialog_default" %>
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
</Head>
<Body>
<Script type = "text/Webpage effects" src = "webpage effects/jquery-1.4.2.min.js"> </script>
<Script src = "js/jquery-ui-1.8.2.custom.min.js" type = "text/javascript"> </script>
<Script type = "text/javascript">
$ (
Function (){
$ ('# Dialog'). dialog ({
Autoopen: false,
Width: 600,
Buttons :{
"OK": function (){
Alert ("OK ");
$ (This). dialog ("close ");
},
"Cancel": function (){
Alert ("cancel ");
$ (This). dialog ("close ");
}
}
});
}
)
Function show ()
{
$ ('# Dialog'). dialog ('open ');
}
Function ajax1 ()
{
$. Ajax ({
Type: "get ",
Url: "action/test. ashx ",
Data: {"time": math. random ()},
Beforesend: function (xmlhttprequest)
{
},
Success: function (msg)
{
Alert (msg );
}
});
}
Function ajax2 ()
{
$. Ajax ({
Type: "post ",
Contenttype: "application/json ",
Url: "action/webservice. asmx/helloworld ",
Data :{},
Datatype: 'json ',
Success: function (msg)
{
Alert (msg );
}
});
}
Function ajax3 (setvalue1, setvalue2)
{
If (setvalue1.length = 0 | setvalue2.length = 0)
{
Alert ('enter the complete text box! ');
Return false;
}
$. Ajax ({
Type: "post ",
Contenttype: "application/json ",
Url: "action/webservice. asmx/helloa ",
Data: "{a: '" + setvalue1 + "', B: '" + setvalue2 + "'}",
Datatype: 'json ',
Success: function (msg)
{
Alert (msg );
}
});
}
// Return the set
Function ajax4 ()
{
$. Ajax ({
Type: "post ",
Contenttype: "application/json ",
Url: "action/webservice. asmx/getarray ",
Data: "{'I': '10 '}",
Success: function (msg ){
Alert (msg );
}
});
}
// Return the composite type
Function ajax5 ()
{
$. Ajax ({
Type: "post ",
Contenttype: "application/json ",
Url: "action/webservice. asmx/getclass ",
Data :"{}",
Success: function (msg ){
$ (Msg). each (function (){
Alert (msg ["id"] + '___' + msg ["value"]);
});
}
});
}
// Return dataset
Function ajax6 ()
{
$. Ajax ({
Type: "post ",
Url: "action/webservice. asmx/getdataset ",
Data :"{}",
Datatype: "xml ",
Success: function (msg ){
$ (Msg). find ('table1'). each (function (){
Alert ($ (this). find ("id"). text () + '___' + $ (this). find ("value"). text ());
});
}
});
}
</Script>
<Form id = "form1" runat = "server">
<Input id = "dialog_link" type = "button" value = "show" onclick = "show ()"/>
<Div id = "dialog" style = "display: none; background-color: aqua; width: 200px; height: 150px;">
Webservice parameter 1 <input type = "text" id = "txtmsg1"/> <br/>
Webservice parameter 2 <input type = "text" id = "txtmsg2"/> <br/>
<Input type = "button" value = "Call the ashx General handler" onclick = "ajax1 ()" id = "btn1"/>
<Input type = "button" value = "Call webservice without Parameters" onclick = "ajax2 ()" id = "btn2"/>
<Input type = "button" value = "webservice" onclick = "ajax3 (txtmsg1.value, txtmsg2.value)" id = "btn3"/>
<Input type = "button" value = "webservice" onclick = "ajax4 ()" id = "btn4"/>
<Input type = "button" value = "webservice of the composite type" onclick = "ajax5 ()" id = "btn5"/>
<Input type = "button" value = "webservice of dataset returned by calling" onclick = "ajax6 ()" id = "btn6"/>
<Div id = "dictionary"> </div>
In dialog!
</Div>
</Form>
</Body>
</Html>

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.