JavaScript Backbone in sails.js sails backbone

I am creating a site using sails and passport for authentication purposes. I've got problems when it come to the use of Jquery and backbone in my code though. It seems that both are down when i tried to use them with sails. What I am trying to do, after user authentication I route the user to home page where all the scripts exists. I put all .js files in the layout.ejs, for exapmle:

<link rel="stylesheet" target='_blank' href="styles/bootstrap-theme.min.css">
<script type="text/javascript" src="js/jquery.js"></script>

Most of css and js files works, but I run into problems with backbone and jquery (and jquerymobile). I am using jQuery 1.10.2 and backbone 1.1.0. Any idea what might be wrong?

In backbone code, I a trying to make Ajax requests via a php file.

   var ProfileList = Backbone.Collection.extend({

                    model: ProfileModel,
                    url: 'data.php'
    });   

What exactly i ve got to do? To add url in routes? Or where should I place data.php file?

EDIT:I ve changed gruntfile.js putting jquery at the top and works fine. Now the problem remains the backbone. I am guessing that my troubles arises since I request access to different domains using passport and backbone. When I am requesting data with data.php I am calling the following jquery code:

xhr.send( ( s.hasContent && s.data ) || null ): jquery.js (line 8706)   

This is an Ajax XMLHttpRequest send request http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp. I generally try to request data from two domains localhost and localhost:1337, so a cross domain issue arises. I ve found that cors(cross origin recource sharing) can handle this issue. Any idea how to allow cors in sails.js??

EDIT: In the route.js file I turn in homepage cors to true:

'/secondscreen': {
view: 'secondsocialscreen/index',
cors: true  

}

I still receiving the same error. Also i changed the variable AllRoutes to true in config/cors.js file. My backbone file works(checked using console), however I cant fetch data. Config/cors.js file is the following:

module.exports.cors = {

    // Allow CORS on all routes by default?  If not, you must enable CORS on a 
    // per-route basis by either adding a "cors" configuration object
    // to the route config, or setting "cors:true" in the route config to
    // use the default settings below.
    allRoutes: true,

    // Which domains which are allowed CORS access?
    // This can be a comma-delimited list of hosts (beginning with http:// or https://)
    // or "*" to allow all domains CORS access.
    origin: '*',

    // Allow cookies to be shared for CORS requests?
    credentials: true,

    // Which methods should be allowed for CORS requests?  This is only used
    // in response to preflight requests (see article linked above for more info)
    methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',

    // Which headers should be allowed for CORS requests?  This is only used
    // in response to preflight requests.
    headers: 'content-type' 
    };

Am I missing something?? Ok I think I ve found something. Actually I am trying to direct to a home.ejs whrere I define a fetching.js (fetching data from data.php and definition of model-controller-views) where backbone code exists. Is it possible this file to work as it is, or I ve to define my MVC from sails?? Also I found that I am trying to get data from localhost:1337 (sails server). However I want to fetch data from apache localhost. How is it possible to request data to apache server while running sails?? In firebug I received the above:

 GET http://localhost/sitec/fetchdata.php?widget=highlights 200 OK 47ms jquery.js (line 8706)
 GET http://localhost/sitec/fetchdata.php?widget=sentiment 200 OK 47ms jquery.js (line 8706)
 GET http://localhost/sitec/fetchdata.php?widget=tagsCloud 200 OK 47ms jquery.js (line 8706)

In response instead of having the object of json data (data.php returns json file), actually I can see the code of data.php file. Weird

Answer:1

We use CORS in sails by modifying the config/routes.js

module.exports.routes = {

'/*': { cors: true }

}

Documented here: http://sailsjs.org/#!documentation/config.routes

Answer:2

In my HTML file, I want to set a check box with specific name as well as id as= checked. How can I acheive this..? eg: <input type="checkbox" name="myName_1" id="1" value="my Value 1"> my ...

In my HTML file, I want to set a check box with specific name as well as id as= checked. How can I acheive this..? eg: <input type="checkbox" name="myName_1" id="1" value="my Value 1"> my ...

  1. check checkbox with specific value
  2. check specific port windows
  3. check specific port linux
  4. check specific port
  5. check specific port status windows
  6. check specific port open windows
  7. check specific word in string php
  8. check specific commit git
  9. check specific gravity of battery
  10. check specific port cmd
  11. check specific character in string php
  12. check specific character in string javascript
  13. check specific port status linux
  14. check specific port netstat
  15. check specific information
  16. check specific open ports cmd
  17. check specific dns server
  18. check specific port nmap
  19. check specific port open linux
  20. check specific port ubuntu

I created an IndexedDB databse named "A" by indexedDB.open method. Now I want to modify the database name to "B", how can I do it? I dont't want to create a new database with new name and copy all ...

I created an IndexedDB databse named "A" by indexedDB.open method. Now I want to modify the database name to "B", how can I do it? I dont't want to create a new database with new name and copy all ...

This fiddle uses multiple series and displays an axis for each of them. Is it possible to use a single series to make several Axes? http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/...

This fiddle uses multiple series and displays an axis for each of them. Is it possible to use a single series to make several Axes? http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/...

  1. highcharts multiple axis
  2. highcharts multiple axis min max
  3. highcharts secondary axis
  4. highcharts two axis
  5. highcharts multiple y axis
  6. highcharts multiple x axis
  7. highcharts multiple y axis scale
  8. highcharts multiple y axis alignment
  9. highcharts multiple x axis categories
  10. highcharts multiple y axis dynamically
  11. highcharts multiple y axis max value
  12. highcharts multiple y axis labels
  13. highcharts multiple x axis label
  14. highcharts multiple y axis grid lines
  15. highcharts multiple y axis tooltip
  16. highcharts multiple y axis title
  17. highcharts tooltip multiple axis
  18. highcharts multiple y axis color
  19. highcharts multiple y axis vertical
  20. highcharts multiple y axis min value

in one of my webpages I want to send the user back to the previous page after some computation, but only if the previous page was a page from my website. So I am wondering if there is an easy way to ...

in one of my webpages I want to send the user back to the previous page after some computation, but only if the previous page was a page from my website. So I am wondering if there is an easy way to ...

  1. check what site is built with
  2. check what site a server is in
  3. check what cms site is using
  4. check site speed
  5. check site
  6. check site traffic
  7. check site safety
  8. check site status
  9. check site availability
  10. check site for malware
  11. check site ip
  12. check site down
  13. check site security
  14. check site performance
  15. check site certificate
  16. check site ranking
  17. check site trust
  18. check site seo
  19. check site ssl
  20. check site speed google