1. Front Page
<a class= "Mui-action-back mui-icon mui-icon-left-nav mui-pull-left" ></a>
<H1 class= "Mui-title" > Enterprise Qualification Inquiry <div class= "Mui-content" >
<form class= "Mui-input-group" accept-charset= "UTF-8" >
<div class= "Mui-input-row" >
<label> Company Name:</label>
<input id= "Entname" type= "text" placeholder= "Please enter Enterprise Name" >
</div>
<div class= "Mui-input-row" >
<label> Certificate Number:</label>
<input id= "Entcertificate" type= "text" class= "mui-input-clear" placeholder= "Please enter Enterprise Certificate number" >
</div>
<button type= "button" id= "btn" class= "mui-btn mui-btn-green mui-btn-block" > Query </button>
</form>
<div id= "Data" >
<div class= "Mui-card" >
<ul class= "Mui-table-view" >
<li class= "Mui-table-view-cell" > Company Name:
<span class= "Targetid" >
</span>
</li>
<li class= "Mui-table-view-cell" > Enterprise Category:
</li>
</ul>
</div>
</div>
</div>
<script src= ". /js/mui.min.js "></script>
<script type= "Text/javascript" >
Mui.init ();
var url = "Http://localhost/SUPEgz/App/search/ent.ashx";
var entname = document.getElementById ("Entname");
var card = document.getElementById ("Entcertificate");
document.getElementById ("Btn"). AddEventListener (' tap ', function () {
ShowData ();
});
function ShowData () {
$.ajax ({
Type: "Post",
Url:url,
Data: {
Name:entname.value,
Card:card.value
},
Success:function (data) {
Mui.toast (' link succeeded ');
Console.log (typeof data); Gets the data to a string
var jsonobj = json.parse (data); Convert data to JavaScript objects
var inner = document.getElementById ("Data");
inner.innerhtml = "";
for (var i = 0, len = jsonobj.tdata.length; i < Len; i++) {
inner.innerhtml + = ' <div class= "Mui-card" ><ul class= "Mui-table-view" ><li class= "Mui-table-view-cell" > Company Name: <span class= "Targetid" > ' + jsonobj.tdata[i]. Fentname + ' </span></li><li class= "Mui-table-view-cell" > Enterprise Category: ' + jsonobj.tdata[i]. Fenttypename + ' <a class= ' look mui-active ' > View Details </a></li></ul></div> ';
}
$ ("#data. Mui-card"). Click (function () {
var i = $ (this). index (); This should be the subscript that gets the click of a, temporarily used Div
var baseUrl = ' ent_info.html ';
var Targetid = document.getelementsbyclassname ("Targetid") [i].innerhtml;
var url = mui.os.plus? Baseurl:baseurl + '? targetid= ' + Targetid;
Mui.openwindow ({
Url:url,
Extras: {
Targetid:targetid
}
})
})
}
})
};
</script>
2. ashx page
<%@ WebHandler language= "C #" class= "ent"%>
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using Ceeyidata;
Using Approve.entitybase;
Using Approve.common;
public class Ent:ihttphandler {
CEEYIDB db = new Ceeyidb ();
public void ProcessRequest (HttpContext context) {
Context. Response.ContentType = "Application/json";
String name = Context. request.params["Name"];
var v = (from T in Db. T_ent_baseinfo
where T.fentname.contains (name)
Select New
{
T.fentname,
T.fenttypename,
T.flicenseno,
}). Take (4);
string s = "{\" tdata\ ":" + Jsonhelper.convert2json (V.tolist ());
s + = "}";
Write (s);
}
public bool IsReusable {
get {
return false;
}
}
<summary>
Return results (specifically for jquery request return value processing)
</summary>
<param name= "S" ></param>
private void Write (string s)
{
Working with cross-domain file headers
HttpContext.Current.Response.AddHeader ("Access-control-allow-origin", "*");
HttpContext.Current.Response.AddHeader ("Access-control-allow-headers", "X-requested-with");
HttpContext.Current.Response.AddHeader ("P3P", "Cp=cao PSA our"); Solve the problem of SessionID lost under IE
return format
HttpContext.Current.Response.ContentType = "Application/json";
jquery callback method
String callbackfun = request["Callbackfun"];
HttpContext.Current.Response.Write (s);
HttpContext.Current.Response.End ();
}
}
Mui.ajax () and ASP. NET SQL Server data interaction "3" final version