English 中文(简体)
把PHP改为AJAX员额
原标题:Trying to get PHP to read AJAX post
  • 时间:2011-11-01 04:55:59
  •  标签:
  • jquery
  • ajax

几乎整天,我一直在追捕我的大理,寻找大 go,看不到为什么不工作。 作为改进我自己的网站的一项实验,我正在检查以下的辅导:http://tuliczine.com/2009/09/simple-ajax- website-jquery/>http://tuliczine.com/2009/09/simple-ajax- website-jquery/ >。 最为重要的是,Ajax/jquery科。

基本上,这部教学法的页数是页数,但我却试图将其改用页数。 因此,从小里夫和实验室那里可以把它作为“家庭.html”和装入内容部分。 出于我之外的原因,这只是不会奏效。 我要说一下,我试图修改法典一的相关部分,以便:

从javascriptloader(只有我修改的结尾部分):

var datastring=url.replace( #! ,  );    //strip the #page part of the hash and leave only the page number

$( #loading ).css( visibility , visible );  //show the rotating gif animation

$.ajax({    //create an ajax request to load_page.php
    type: "POST",
    url: "load_file.php",
    data: datastring,   //with the page number as a parameter
    dataType: "html",   //expect html to be returned
    async: false,
    success: function(msg){

        if(parseInt(msg)!=0)    //if no errors
        {
            $( #content ).html(msg);    //load the returned html into pageContet
            $( #loading ).css( visibility , hidden );   //and hide the rotating gif
        }
    }

});

And the entire php file:

    <?php 
$url = $_POST[ datastring ];

if(file_exists(  .$url. .html ))
echo file_get_contents(  .$url. .html );

else echo  There is no such page! ;

?>

I wanted to learn on my own and figure this out but honestly I don t get it :/ There s no cross domain problem as far as I can tell. Anybody know what I m missing? Figured I d ask here since it s likely to be more traveled than that tutorial s site, although if I find a solution I ll go over there and post it in the comments too so others may avoid my pain. XD

最佳回答

你们需要把你的《专业指导手册》数据作为关键的、价值合理的数据。

改变您的数据,以便:

data: "datastring="+datastring
问题回答

您是确定PHP档案所研究的数据参数的灯塔。

The js file:

var datastring=url.replace( #! ,  );    //strip the #page part of the hash and leave only the page number

$( #loading ).css( visibility , visible );  //show the rotating gif animation

$.ajax({    //create an ajax request to load_page.php
    type: "POST",
    url: "load_file.php",
    data:  datastring= +datastring,   //with the page number as a parameter
    dataType: "html",   //expect html to be returned
    async: false,
    success: function(msg){

        if(parseInt(msg)!=0)    //if no errors
        {
            $( #content ).html(msg);    //load the returned html into pageContet
            $( #loading ).css( visibility , hidden );   //and hide the rotating gif
        }
    }

});

页: 1

<?php  
$url = $_REQUEST[ datastring ];
echo $url;

if(file_exists(  .$url. .html ))
echo file_get_contents(  .$url. .html );

else echo  There is no such page! ;

?>

页: 1

In your jQuery AJAX try changing:

data: datastring

:

data:  datastring=  + datastring




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签