??yy 2015-01-02 16:49 采纳率: 0%
浏览 48

jQuery / AJAX语法-PHP与ASP

I'm working on a tutorial that explains how to use jQuery to Get and Post data from an external page. The tutorials are generally simple, but this one is confusing because the external data is stored in pages with an .asp extension, which I know nothing about.

How should I modify the text from these pages so it works with PHP?

<%
response.write("This is some text from an external ASP file.")
%>

<%
dim fname,city
fname=Request.Form("name")
city=Request.Form("city")
Response.Write("Dear " & fname & ". ")
Response.Write("Hou live well in " & city & ".")
%>
  • 写回答

1条回答 默认 最新

  • weixin_33717298 2015-01-02 17:07
    关注

    In FE Script jQuery like this. "test.php"

      $.ajax({
        type: "POST",
        url: 'test.php',
        dataType: 'json',
        data: {"data":"check"},
        success: function(data){
            alert(data.value1);
            alert(data.value2);
        }
     });
    

    PHP Script

    <?php
        if(isset($_POST['data']) && $_POST['data'] == 'check'){
           //Data 1
             $data['value1'] = 'Data 1 Got Successfully';
            //Data 2
             $data['value2'] = 'Data 2 Got Successfully';
             $resonse = json_encode($data);
             echo $response;
        }
    ?>
    

    I hope you're aware of how to inject the response to DOM in AJAX success function

    评论

报告相同问题?