Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Hi I am using Curl to return a AJAX request to solve a cross domain browser issue, but it returns far more html than I am interested in, I would also like to have the response that is passed back to the client in a JSON format, here is an example of returned HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"><head><title>

</title></head><body><form name="form1" method="post" action="tenHsServer.aspx?t=ab&amp;f=DeviceStatus&amp;d=C5&amp;" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTkzNDcxNzcwM2Rk3QALsTMudMGaJ2N5Q4Yb8Kvd/Xg=" />

 <span id="Result">C5:3;</span>
 </form></body></html>

I am only interested in the id="result" text "C5:3" and really only the 3 part.

can I alter any parameters while configuring CURL to achieve this?

current Curl script,

  $url = $_POST['url'];
  unset($_POST['url']);
  $fields_string = "";
  //url-ify the data for the POST
  foreach($_POST as $key=>$value) {
   $fields_string .= $key.'='.urlencode($value).'&';
   }
  rtrim($fields_string,"&");
   //open connection
   $ch = curl_init();
   //set the url, number of POST vars, POST data
   $url .= '&';
   $url .= $fields_string;
   curl_setopt($ch,CURLOPT_URL,$url);
   //execute post
   $string = curl_exec($ch);

  curl_close($ch);

If Curl can't do this what else can I do? sorry it terminology is wrong, or asking something just plan wrong everything is new, much banging of head!!!!

Thanks

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.