The same source code can be run locally and cannot be executed on the server. Solution

Source: Internet
Author: User
The same source code can be run locally and cannot be executed on the server. I wrote an ajax request. I tested it locally, but I couldn't execute it on the server. Why? You have never had this situation. AjaxJScriptcodefunctionshowList (id) {the same source code can be run locally and cannot be executed on the server.
I wrote an ajax request. I tested it locally, but I couldn't execute it on the server. Why?

You have never had this situation.

Ajax
JScript code
  Function showList (id) {url = 'ajaxlist. php '; $. get (url, {id: id}, function (e) {if (e = 0) {$ ("# info" ).html ("No payment information ");} else {$ ("# info" ).html (e );}});}

PHP code
  
  Db_Query($sql);$row=$news->Db_Fetch_Array();if($row){    echo json_decode($row['paytype']);}else{    die(0);}?>


Server:



------ Solution --------------------
First, check whether the server supports json. should json_encode be used?
------ Solution --------------------
Is the database matched? what is the table name of the user name and password?
------ Solution --------------------
Url = 'ajaxlist. php'; the path is incorrect. Try it with absolute
------ Solution --------------------
Use var_dump to output background data and firebug to check whether the data format passed in the background is correct. Is it a traditional ajax problem such as bom header and encoding?
------ Solution --------------------
Discussion

Use var_dump to output background data and firebug to check whether the data format passed in the background is correct. Is it a traditional ajax problem such as bom header and encoding?

------ Solution --------------------
$. Get (url, {id: id },
Function (e ){
If (e = 0 ){
$ ("# Info" ).html ("No payment information ");
} Else {
$ ("# Info" ).html (e );
}
}); Is your get method type supposed to be json transfer.
------ Solution --------------------
$. Get (url, {id: id },???
$. Get (url, {'id': id },
I wonder if I have a mistake

Run the server program separately to check whether the returned results are normal.

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.