当前位置: 动力学知识库 > 问答 > 编程问答 >

node.js - Not able to get window.location.search value in HTML - jQueryMobile

问题描述:

My javascript code looks like this

var query = window.location.search.replace('?','');

fetchContent(apiUrl + 'service/' + query + '?callback=?', function(data) {

$('.content').append(data).trigger('create');

});

I am using jQueryMobile, nodeJS for services and views. Also, using EJS templates to display data.

The problem is that I am not able to get value for variable query in the above code and hence the next following lines form up a parameter 'apiUrl/service/?callback=?' for fetchContent method which is a wrong URL for my service. The correct parameter for my fetchContent method should be 'apiUrl/service/1234?callback=?'.

Interesting thing is that this code works fine when I open the link in new tab. URL for the above HTML page in my code is some.html?1234. According to this the value in JS code should be 1234 but it is empty.

分享给朋友:
您可能感兴趣的文章:
随机阅读: