Based on the example you have here, it seems like having your php file
return a JSON object may suit your needs a little better than
returning an entire page.  However, if you wanted to get the data in
the way you're talking about, set the 'dataType' parameter to 'html'
in your $.ajax function, and then in your success function, insert the
html response into an element on the page, and then get the values
from there like you normally would with jQuery.  So in order to
achieve what you are talking about above, your ajax function would
look something like this:

$.ajax({
     url: 'temp.php',
     data: 'ID=1&NUMBER=123',
     dataType: 'html',
     cache: false,
     error:  function(msg) {alert("Error Saved: " + msg);},
     success: function(html) {
          $('#ajax-response-container').html(html);
          var id = $('#ajax-response-container #header p').text();
          var number = $('#ajax-response-container #header2 p').text
();
          //whatever else you want to do with the returned values
     },
     complete: function() {$.unblockUI();} });

and then in your HTML be sure to have the element

<div id="ajax-response-container"></div>

I did a brief test on my local machine and that seemed to work.
However, I really think that you should consider passing the values in
a JSON object instead of an entire page.  Could you perhaps provide a
link to where you are trying to implement this code?  It might help me
understand what you are trying to achieve a little better.  Please
feel free to email me if you have questions at
nofxbassist1...@gmail.com

On Apr 23, 4:55 am, Colonel <tcolo...@gmail.com> wrote:
> Anybody ???
>
> On 23 апр, 04:26, Colonel <tcolo...@gmail.com> wrote:
>
> > How I can get content from remote file by $.ajax?
>
> > For example I have some file temp.php:
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> > <html>
> > <head>
> >  <title>Test file</title>
> >  <meta http-equiv="Content-Type" content="text/html;
> > charset=windows-1251">
> > </head>
> > <body>
> >  <?
> >  $id = isset($_GET["ID"]) ? $_GET["ID"] : "";
> >  $number = isset($_GET["NUMBER"]) ? $_GET["NUMBER"] : "";
> >  echo "<p><b>id =</b>" . $id . "</p>";
> >  echo "<p>number = " . $number . "</p>";
> >  ?>
> >  <div id="header"><p>Some text in div header - <?=$id?></p></div>
> >  <div id="header2"><p>Some text in header2 - <?=$number?></p></div>
> > </body>
> > </html>
>
> > and Am using $.ajax:
>
> > $.ajax({url: 'temp.php',
> >             data: "ID=1&NUMBER=123",
> >             cache: false,
> >             error:  function(msg) {alert("Error Saved: " + msg);},
> >             success: function(msg) {alert("Data Saved: " + msg);},
> >             complete: function() {$.unblockUI();}
> >            });
>
> > how I can get for example content only from div with id=header2 or
> > both divs (not hole data - msg)?
>
> > Thanks.

Reply via email to