get file

JavaScript related questions should go here.
Post Reply
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

get file

Post 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
I would put a signature.. BUT, i don't have the time.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: get file

Post 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...
Image
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Re: get file

Post 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?
I would put a signature.. BUT, i don't have the time.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: get file

Post 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 ;)
Image
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Re: get file

Post 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 :(
I would put a signature.. BUT, i don't have the time.
Post Reply