开发者

GET AJAX query string parameters in Theme template - Drupal

There is a callback function that includes a js and then returns a theme. The js included in turn makes an AJAX request to another callback function with some query string parameters.

Here is the code snippet: Page requested: http://example.com/abc

function abc()
{
  drupal_add_js('sign-in.js');
  return theme('mypage');
}

//sign-in.js

ajaxRequest = $.ajax({
    type: "GET",
 开发者_StackOverflow中文版   url: "/xyz",
    data: 'channels='+noofchannels',
    ....
});

I want to get this 'channels' parameter value in mypage.tpl.php theme file . Is this possible and how it can be done?


Since the AJAX call out to /xyz happens after the /abc page loading is complete, I don't think this is possible...

Typically, the 'success' function after the AJAX call would modify something on your page, i.e. take the 'channels' value and print it out somewhere.

But since the value of 'channels' is already known in your example (from the var 'noofchannels'), you could use JS to put it somewhere on your page before your AJAX call.

Why do you need the value of 'channels' inside your mypage.tpl.php file?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜