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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀