Page 1 of 1

get file

Posted: Tue May 24, 2011 11:02 am
by ashwood
i need to use jquery for something.. but i need to get a php file containing the data so that jquery (js) will output the content of this file.

if you get that..

thanks
ash

Re: get file

Posted: Tue May 24, 2011 1:58 pm
by jacek
you cant ge the contents of a file on the server directly, you will have to do an ajax request for the file...

Re: get file

Posted: Thu May 26, 2011 2:21 pm
by ashwood
so how would i do this?

i found this..
$.ajax({
        url: "xxx/xxx.php", 
        type: "GET",
        data: data,     
        cache: false,
        success: function (html) {
            alert("HTLM = " + html);
            $('#product-list').html(html);
            }
 });
would i put it in a function or just js tags?

Re: get file

Posted: Thu May 26, 2011 3:37 pm
by jacek
Looks like jQuery to me... so I can't really help with that :?
ashwood wrote:would i put it in a function or just js tags?
If it is correct, it can work in both of those situations ;)

Re: get file

Posted: Thu May 26, 2011 5:41 pm
by ashwood
this is what ive got

index.php
<html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jq ... "></script>
<script type='text/javascript' langauge='javascript'>
 $.ajax({
        url: "source.php",
        type: "GET",
        data: data,     
        cache: false,
        success: function (html) {
            alert("HTLM = " + html);
            $('#jquery-div').html(html);
            }
 });
</script>
</head>
<body>
<div id='jquery-div'></div>
</body>
</html>
source.php
<?php

echo "Work work work work work :)";

?>
but nothing :(