Home > Backend Development > PHP Tutorial > How can I add the data returned by mui.ajax to the web page?

How can I add the data returned by mui.ajax to the web page?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-06 13:53:17
Original
1048 people have browsed it

When the APP is running, the following error occurs. How can I add the data returned by mui.ajax to the web page

Uncaught TypeError: Property 'data' of object function (b,c){if(c=c||a,!b)return j();if("object"==typeof b)return i.isArrayLike (b)?j(i.slice.call(b),null):j([b],null);if("function"==typeof b)return i.ready(b);if("string" ==typeof b)try{if(b=b.trim()......on at index2.html:38


function showHint(str) {
if (str.length == 0) {
document.getElementById("txtHint").innerHTML = "";
return;
} else {

var url = 'http://hktc.erufa.com/show.php'
mui.ajax(url,{

data:{
q:str
},

dataType:'html',
type:'get',//HTTP request type
timeout:30000,//The timeout is set to 10 seconds;

success:function(data){

//The server returns a response and analyzes whether the login is successful based on the response result;
document.getElementById("txtHint").innerHTML = data;
},

error:function(xhr,type,errorThrown){

//Exception handling;
console.log(type);
}

});

Start typing a name in the input field below:



First name:

Suggestions:


php code

header("Access-Control-Allow-Origin:*");
header("Content-type:text/html; charset=utf-8");

$a[] = "Anna";
$a[] = "Brittany";
$a[] = "Cinderella";
$a[] = "Diana";
$a[] = "Eva";
$a[] = "Fiona";
$a[] = "Gunda";
$a[] = "Hege";
$ a[] = "Inga";
$a[] = "Johanna";
$a[] = "Kitty";
$a[] = "Linda";
$a[ ] = "Nina";
$a[] = "Ophelia";
$a[] = "Petunia";
$a[] = "Amanda";
$a[] = "Raquel";
$a[] = "Cindy";
$a[] = "Doris";
$a[] = "Eve";
$a[] = "Evita ";
$a[] = "Sunniva";
$a[] = "Tove";
$a[] = "Unni";
$a[] = "Violet";
$a[] = "Liza";
$a[] = "Elizabeth";
$a[] = "Ellen";
$a[] = "Wenche";
$a[] = "Vicky";

// get the q parameter from URL
$q = $_REQUEST["q"];

$hint = "";

// lookup all hints from array if $q is different from ""
if ($q !== "") {

<code>$q = strtolower($q);
$len=strlen($q);
foreach($a as $name) {
    if (stristr($q, substr($name, 0, $len))) {
        if ($hint === "") {
            $hint = $name;
        } else {
            $hint .= ", $name";
        }
    }
}</code>
Copy after login
Copy after login

}

// Output "no suggestion" if no hint was found or output correct values ​​
echo $hint === "" ? "no suggestion" : $hint;
?>

Reply content:

When the APP is running, the following error occurs. How can I add the data returned by mui.ajax to the web page

Uncaught TypeError: Property 'data' of object function (b,c){if(c=c||a,!b)return j();if("object"==typeof b)return i.isArrayLike (b)?j(i.slice.call(b),null):j([b],null);if("function"==typeof b)return i.ready(b);if("string" ==typeof b)try{if(b=b.trim()......on at index2.html:38


function showHint(str) {
if (str.length == 0) {
document.getElementById("txtHint").innerHTML = "";
return;
} else {

var url = 'http://hktc.erufa.com/show.php'
mui.ajax(url,{

data:{
q:str
},

dataType:'html',
type:'get',//HTTP request type
timeout:30000,//The timeout is set to 10 seconds;

success:function(data){

//The server returns a response and analyzes whether the login is successful based on the response result;
document.getElementById("txtHint").innerHTML = data;
},

error:function(xhr,type,errorThrown){

//Exception handling;
console.log(type);
}

});

Start typing a name in the input field below:



First name:

Suggestions:


php code

header("Access-Control-Allow-Origin:*");
header("Content-type:text/html; charset=utf-8");

$a[] = "Anna";
$a[] = "Brittany";
$a[] = "Cinderella";
$a[] = "Diana";
$a[] = "Eva";
$a[] = "Fiona";
$a[] = "Gunda";
$a[] = "Hege";
$a[] = "Inga";
$a[] = "Johanna";
$a[] = "Kitty";
$a[] = "Linda";
$a[] = "Nina";
$a[] = "Ophelia";
$a[] = "Petunia";
$a[] = "Amanda";
$a[] = "Raquel";
$a[] = "Cindy";
$a[] = "Doris";
$a[] = "Eve";
$a[] = "Evita";
$a[] = "Sunniva";
$a[] = "Tove";
$a[] = "Unni";
$a[] = "Violet";
$a[] = "Liza";
$a[] = "Elizabeth";
$a[] = "Ellen";
$a[] = "Wenche";
$a[] = "Vicky";

// get the q parameter from URL
$q = $_REQUEST["q"];

$hint = "";

// lookup all hints from array if $q is different from ""
if ($q !== "") {

<code>$q = strtolower($q);
$len=strlen($q);
foreach($a as $name) {
    if (stristr($q, substr($name, 0, $len))) {
        if ($hint === "") {
            $hint = $name;
        } else {
            $hint .= ", $name";
        }
    }
}</code>
Copy after login
Copy after login

}

// Output "no suggestion" if no hint was found or output correct values
echo $hint === "" ? "no suggestion" : $hint;
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
html5 validation for symfony 2.1
From 1970-01-01 08:00:00
0
0
0
The difference between HTML and HTML5
From 1970-01-01 08:00:00
0
0
0
html5 show hide
From 1970-01-01 08:00:00
0
0
0
Can PDF files run HTML5 and Javascript?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template