DragonWar% 2014-04-11 14:09 采纳率: 0%
浏览 109

从AJAX页面执行URL

I'm looking for a method to execute a URL from an AJAX page.

The scenario is like im creating a bidding page with 3 products. Time limit is 5 second and after finishing 5 seconds, i wanted to insert the selected product details to database (this is why we need to execute a URL) and the loop should again start from 5 ..4..3..

The issue i'm facing right now is, i can not able to execute a url from this ajax call. I tried CURL; but this is not working.

$.ajax({
  url: "test.php",
  context: document.body
}).done(function() {
  $( this ).addClass( "done" );
});

test.php
--------
curlSession = curl_init();

// HERE I NEED TO EXECUTE THE URL

curl_setopt($curlSession, CURLOPT_URL, 'http://192.168.1.132/oxid/index.php?fnc=tobasket&aid=378442f7aa427425c741607aa3440ee8&am=1');
curl_exec($curlSession);
curl_close($curlSession);

Regards, Tismon

  • 写回答

1条回答 默认 最新

  • weixin_33705053 2014-04-11 14:18
    关注

    You can try this and confirm if this solves your purpose:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, 'headers that you want to pass');
    curl_setopt($ch, CURLOPT_URL, 'url/that/you/want/to/call');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);
    

    Posted thinking that you need help on basic curl

    For using Ajax, you should look at this post.

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示